/* ============================================================
   sora.market — A Miniature Isometric Marketplace
   ============================================================ */

:root {
    /* Color palette — Japanese craft marketplace */
    --color-terracotta: #C4704B;   /* Kiln Terracotta — primary surface */
    --color-bisque:     #F5E6D3;   /* Bisque Clay — tile background */
    --color-charcoal:   #2D2520;   /* Warm Charcoal — headings */
    --color-umber:      #594A42;   /* Fired Umber — body text */
    --color-sage:       #3D5A3A;   /* Market Sage — accents */
    --color-spice:      #D4854A;   /* Spice Orange — hover/highlight */
    --color-rice:       #FAF4EC;   /* Rice Paper — soft neutrals */
    --color-smoke:      #1E1613;   /* Kiln Smoke — deep ground */
    --color-dust:       #8B7668;   /* Dusty brown — secondary tone */

    /* Typography */
    --font-heading: 'Nunito', system-ui, sans-serif;
    --font-body:    'Quicksand', system-ui, sans-serif;
    --font-tag:     'M PLUS Rounded 1c', 'Nunito', sans-serif;

    /* Motion */
    --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);

    /* Layout */
    --gap: 24px;
    --tile-radius: 12px;
    --district-pad: 120px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--color-terracotta);
    color: var(--color-charcoal);
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.65;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
}

/* Crosshatch floor texture */
.floor-texture {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 1;
}

.floor-texture svg {
    width: 100%;
    height: 100%;
    display: block;
}

section {
    position: relative;
    z-index: 1;
}

/* ============================================================
   GATE SECTION — opening sequence
   ============================================================ */

.gate-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 48px;
    position: relative;
}

.gate-frame {
    text-align: center;
    max-width: 640px;
    margin: 0 auto;
}

.gate-illustration {
    width: clamp(220px, 32vw, 320px);
    margin: 0 auto 36px;
    transform: scale(0.8);
    opacity: 0;
    transition: transform 600ms var(--ease-pop), opacity 500ms ease-out;
}

.gate-illustration.in {
    transform: scale(1);
    opacity: 1;
}

.gate-illustration svg {
    width: 100%;
    height: auto;
    display: block;
}

.site-title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: clamp(2.4rem, 5.5vw, 3.8rem);
    line-height: 1.1;
    letter-spacing: 0.04em;
    color: var(--color-charcoal);
    margin-bottom: 18px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out);
}

.site-title.in {
    opacity: 1;
    transform: translateY(0);
}

.site-tagline {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.6vw, 1.2rem);
    color: var(--color-umber);
    max-width: 480px;
    margin: 0 auto 64px;
    opacity: 0;
    transition: opacity 600ms var(--ease-out);
    transition-delay: 400ms;
}

.site-tagline.in {
    opacity: 1;
}

.scroll-arrow {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    opacity: 0;
    transition: opacity 600ms var(--ease-out);
    transition-delay: 800ms;
    animation: arrowPulse 2s ease-in-out infinite;
}

.scroll-arrow.in {
    opacity: 1;
}

.scroll-arrow svg {
    width: 100%;
    height: 100%;
    display: block;
}

@keyframes arrowPulse {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(8px); }
}

/* ============================================================
   DISTRICT SECTIONS
   ============================================================ */

.district {
    padding: var(--district-pad) 48px;
    max-width: 1180px;
    margin: 0 auto;
}

.district-header {
    margin-bottom: 56px;
    max-width: 720px;
}

.district-marker {
    display: inline-block;
    width: 40px;
    height: 40px;
    margin-bottom: 20px;
}

.district-marker svg {
    width: 100%;
    height: 100%;
    display: block;
}

.district-eyebrow {
    display: block;
    font-family: var(--font-tag);
    font-weight: 500;
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--color-rice);
    margin-bottom: 10px;
    opacity: 0.85;
}

.district-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    line-height: 1.2;
    letter-spacing: 0.01em;
    color: var(--color-charcoal);
    margin-bottom: 14px;
}

.district-desc {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--color-umber);
    max-width: 560px;
    font-size: clamp(1rem, 1.3vw, 1.1rem);
}

.header-pattern-strip {
    margin-top: 28px;
    height: 24px;
    width: 100%;
    max-width: 360px;
}

.stitching-svg {
    width: 100%;
    height: 24px;
    display: block;
}

.stitch-line {
    stroke-dasharray: 280;
    stroke-dashoffset: 280;
    transition: stroke-dashoffset 1200ms var(--ease-out);
}

.district.in .stitch-line {
    stroke-dashoffset: 0;
}

/* ============================================================
   GRID LAYOUTS
   ============================================================ */

.grid {
    display: grid;
    gap: var(--gap);
}

.grid-hero {
    grid-template-columns: 1fr;
}

.grid-three {
    grid-template-columns: repeat(3, 1fr);
}

.grid-stagger {
    grid-template-columns: repeat(3, 1fr);
}

.grid-stagger > .tile:nth-child(2n) {
    transform: translateY(36px);
}

.grid-dense {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.grid-stories {
    grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 980px) {
    .grid-three,
    .grid-stagger,
    .grid-dense,
    .grid-stories {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-stagger > .tile:nth-child(2n) {
        transform: translateY(24px);
    }
}

@media (max-width: 640px) {
    .district {
        padding: 72px 24px;
    }
    .grid-three,
    .grid-stagger,
    .grid-dense,
    .grid-stories {
        grid-template-columns: 1fr;
    }
    .grid-stagger > .tile:nth-child(2n) {
        transform: translateY(0);
    }
}

/* ============================================================
   TILES
   ============================================================ */

.tile {
    position: relative;
    background: var(--color-bisque);
    border-radius: var(--tile-radius);
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(60, 35, 20, 0.12);
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    opacity: 0;
    transform: scale(0.92) translateY(8px);
    transition:
        opacity 520ms var(--ease-out),
        transform 520ms var(--ease-pop),
        box-shadow 300ms var(--ease-out);
    cursor: default;
}

.district.in .tile {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Re-apply stagger Y offset after intersection */
.district.in .grid-stagger > .tile:nth-child(2n) {
    transform: scale(1) translateY(36px);
}

@media (max-width: 980px) {
    .district.in .grid-stagger > .tile:nth-child(2n) {
        transform: scale(1) translateY(24px);
    }
}

@media (max-width: 640px) {
    .district.in .grid-stagger > .tile:nth-child(2n) {
        transform: scale(1) translateY(0);
    }
}

.tile-pattern-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    border-radius: var(--tile-radius);
    overflow: hidden;
}

.tile-pattern-overlay svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Hover state — uroko fish-scale overlay + lift */
.tile::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M0 12 a12 12 0 0 1 24 0 M-12 24 a12 12 0 0 1 24 0 M12 24 a12 12 0 0 1 24 0' fill='none' stroke='%232D2520' stroke-width='0.7'/%3E%3C/svg%3E");
    opacity: 0;
    pointer-events: none;
    z-index: 1;
    transition: opacity 240ms var(--ease-out);
    border-radius: var(--tile-radius);
}

.tile:hover {
    transform: scale(1.04) translateY(-2px) !important;
    box-shadow: 0 8px 24px rgba(60, 35, 20, 0.18);
    transition:
        transform 220ms var(--ease-pop),
        box-shadow 220ms var(--ease-out);
}

.tile:hover::after {
    opacity: 0.08;
}

.tile:hover .iso-icon-frame,
.tile:hover .iso-icon-mini,
.tile:hover .hero-diorama,
.tile:hover .story-illust {
    transform: translateY(-2px);
}

.tile-body,
.story-body {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tag {
    font-family: var(--font-tag);
    font-weight: 500;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-sage);
    align-self: flex-start;
}

.tag-sage {
    color: var(--color-sage);
}

.tag-secondary {
    color: var(--color-dust);
}

.tile-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: clamp(1.1rem, 1.6vw, 1.35rem);
    line-height: 1.3;
    letter-spacing: 0.005em;
    color: var(--color-charcoal);
}

.tile-title-sm {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.3;
    color: var(--color-charcoal);
}

.tile-text {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--color-umber);
    font-size: 0.96rem;
}

.tile-price {
    font-family: var(--font-tag);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    color: var(--color-sage);
    margin-top: 4px;
}

.tile-link {
    font-family: var(--font-tag);
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-sage);
    margin-top: 6px;
    transition: color 200ms var(--ease-out);
}

.tile:hover .tile-link {
    color: var(--color-spice);
}

.link-arrow {
    display: inline-block;
    transition: transform 220ms var(--ease-pop);
}

.tile:hover .link-arrow {
    transform: translateX(4px);
}

/* ============================================================
   HERO TILE
   ============================================================ */

.tile-hero {
    padding: 0;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    align-items: stretch;
    min-height: 360px;
}

.hero-diorama {
    position: relative;
    background: linear-gradient(160deg, var(--color-bisque), var(--color-rice));
    overflow: hidden;
    z-index: 1;
    transition: transform 240ms var(--ease-pop);
}

.diorama-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.depth-back  { transition: transform 220ms var(--ease-out); }
.depth-mid   { transition: transform 220ms var(--ease-out); }
.depth-front { transition: transform 220ms var(--ease-out); }

.tile-hero .tile-body {
    padding: 36px 32px;
    justify-content: center;
}

@media (max-width: 720px) {
    .tile-hero {
        grid-template-columns: 1fr;
    }
    .hero-diorama {
        min-height: 220px;
    }
}

/* ============================================================
   ICON FRAMES
   ============================================================ */

.iso-icon-frame {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: linear-gradient(160deg, var(--color-rice), var(--color-bisque));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    z-index: 1;
    transition: transform 240ms var(--ease-pop);
}

.iso-icon-wide {
    aspect-ratio: 16 / 9;
}

.iso-icon-mini {
    aspect-ratio: 1 / 1;
}

.iso-icon {
    width: 84%;
    height: 84%;
    display: block;
}

/* ============================================================
   MINI TILES (interior alleys)
   ============================================================ */

.tile-mini {
    padding: 18px;
    gap: 12px;
}

.tile-mini .tile-body {
    gap: 6px;
}

/* ============================================================
   STORY TILES
   ============================================================ */

.tile-story {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.story-illust {
    background: linear-gradient(160deg, var(--color-bisque), var(--color-rice));
    padding: 24px;
    transition: transform 240ms var(--ease-pop);
}

.story-illust .iso-icon {
    width: 80%;
    height: auto;
    margin: 0 auto;
    display: block;
}

.story-body {
    padding: 28px 32px 32px;
    gap: 12px;
}

@media (max-width: 720px) {
    .grid-stories {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   HANKO + DOTTED RULE
   ============================================================ */

.hanko-row {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-top: 64px;
}

.hanko {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    transform: rotate(-6deg);
}

.dotted-rule {
    flex: 1;
    height: 6px;
}

.dotted-rule svg {
    width: 100%;
    height: 6px;
    display: block;
}

/* ============================================================
   CLOSING SECTION
   ============================================================ */

.closing {
    position: relative;
    min-height: 100vh;
    padding: 160px 48px 96px;
    overflow: hidden;
    isolation: isolate;
}

.closing-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        rgba(196, 112, 75, 0) 0%,
        rgba(45, 37, 32, 0.6) 30%,
        var(--color-smoke) 70%,
        var(--color-smoke) 100%);
    z-index: 0;
    pointer-events: none;
}

.closing-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 640px;
    margin: 0 auto;
}

.closing-illust {
    width: clamp(260px, 40vw, 360px);
    margin: 0 auto 40px;
}

.closing-illust svg {
    width: 100%;
    height: auto;
    display: block;
}

.lantern-glow {
    transform-origin: center;
    animation: lanternPulse 3s ease-in-out infinite;
}

@keyframes lanternPulse {
    0%, 100% { opacity: 0.16; transform: scale(1); }
    50%      { opacity: 0.34; transform: scale(1.12); }
}

.closing-eyebrow {
    font-family: var(--font-tag);
    font-weight: 500;
    font-size: 0.82rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--color-spice);
    margin-bottom: 16px;
}

.closing-title {
    font-family: var(--font-tag);
    font-weight: 700;
    font-size: clamp(2.4rem, 5vw, 3.4rem);
    letter-spacing: 0.05em;
    color: var(--color-bisque);
    margin-bottom: 24px;
    animation: closingPulse 3s ease-in-out infinite;
}

@keyframes closingPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.78; }
}

.closing-text {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--color-bisque);
    opacity: 0.82;
    font-size: 1.05rem;
    margin-bottom: 24px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.closing-meta {
    font-family: var(--font-tag);
    font-weight: 500;
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    color: var(--color-dust);
    text-transform: uppercase;
}

/* ============================================================
   FLOATING NAV (radial)
   ============================================================ */

.floating-nav {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 100;
}

.nav-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-sage);
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: 0 6px 18px rgba(30, 22, 19, 0.28);
    transition: transform 280ms var(--ease-pop), background 200ms ease-out;
    position: relative;
    z-index: 2;
}

.nav-toggle:hover {
    transform: scale(1.08);
    background: #4d6e49;
}

.nav-line {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--color-bisque);
    border-radius: 2px;
    transition: transform 240ms var(--ease-pop), opacity 200ms ease-out;
}

.floating-nav.open .nav-toggle {
    transform: rotate(90deg);
}

.floating-nav.open .nav-line:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.floating-nav.open .nav-line:nth-child(2) {
    opacity: 0;
}
.floating-nav.open .nav-line:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.nav-radial {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 240px;
    height: 240px;
    pointer-events: none;
}

.nav-radial-bg {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    overflow: hidden;
    background: var(--color-rice);
    opacity: 0;
    transform: scale(0.4);
    transform-origin: 100% 100%;
    transition: opacity 320ms var(--ease-out), transform 360ms var(--ease-pop);
    box-shadow: 0 8px 32px rgba(30, 22, 19, 0.24);
}

.nav-radial-bg svg {
    width: 100%;
    height: 100%;
    display: block;
}

.floating-nav.open .nav-radial-bg {
    opacity: 1;
    transform: scale(1);
}

.nav-item {
    position: absolute;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-bisque);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--color-charcoal);
    box-shadow: 0 4px 12px rgba(30, 22, 19, 0.16);
    opacity: 0;
    transform: translate(0, 0) scale(0.4);
    pointer-events: none;
    transition:
        opacity 320ms var(--ease-out),
        transform 420ms var(--ease-pop),
        background 200ms ease-out;
    transition-delay: calc(var(--i) * 40ms);
    cursor: pointer;
    /* Default position — center-anchored */
    bottom: 0;
    right: 0;
}

.nav-icon {
    width: 22px;
    height: 22px;
    display: block;
}

.nav-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.nav-label {
    position: absolute;
    bottom: -22px;
    font-family: var(--font-tag);
    font-weight: 500;
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-charcoal);
    opacity: 0;
    transition: opacity 200ms var(--ease-out);
    white-space: nowrap;
}

.nav-item:hover .nav-label {
    opacity: 1;
}

.nav-item:hover {
    background: var(--color-spice);
}

/* Radial positions — calculated for 7 items along an arc */
.floating-nav.open .nav-item {
    opacity: 1;
    pointer-events: auto;
}

.floating-nav.open .nav-item[data-target="gate"]     { transform: translate(-180px, 0)    scale(1); }
.floating-nav.open .nav-item[data-target="entrance"] { transform: translate(-166px, -68px) scale(1); }
.floating-nav.open .nav-item[data-target="pottery"]  { transform: translate(-128px, -128px) scale(1); }
.floating-nav.open .nav-item[data-target="textile"]  { transform: translate(-68px, -166px)  scale(1); }
.floating-nav.open .nav-item[data-target="alleys"]   { transform: translate(0, -180px)     scale(1); }
.floating-nav.open .nav-item[data-target="stories"]  { transform: translate(64px, -150px) scale(1); }
.floating-nav.open .nav-item[data-target="closing"]  { transform: translate(110px, -110px) scale(1); }

@media (max-width: 640px) {
    .floating-nav { bottom: 20px; right: 20px; }
    .nav-radial { width: 200px; height: 200px; }
    .floating-nav.open .nav-item[data-target="gate"]     { transform: translate(-150px, 0)     scale(1); }
    .floating-nav.open .nav-item[data-target="entrance"] { transform: translate(-140px, -56px) scale(1); }
    .floating-nav.open .nav-item[data-target="pottery"]  { transform: translate(-108px, -108px) scale(1); }
    .floating-nav.open .nav-item[data-target="textile"]  { transform: translate(-56px, -140px)  scale(1); }
    .floating-nav.open .nav-item[data-target="alleys"]   { transform: translate(0, -150px)     scale(1); }
    .floating-nav.open .nav-item[data-target="stories"]  { transform: translate(50px, -126px) scale(1); }
    .floating-nav.open .nav-item[data-target="closing"]  { transform: translate(94px, -94px) scale(1); }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    .gate-illustration,
    .site-title,
    .site-tagline,
    .scroll-arrow,
    .tile {
        opacity: 1 !important;
        transform: none !important;
    }
    .stitch-line { stroke-dashoffset: 0 !important; }
}
