@layer reset, base, layout, components, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  button, input, select, textarea { font: inherit; }
  button { cursor: pointer; color: inherit; background: none; border: 0; }
  a { color: inherit; text-decoration: none; }
  img { display: block; max-width: 100%; }
}

@layer base {
  :root { color-scheme: dark; --bg: #0c0c0c; --text: #d7e2ea; --accent: #2563eb; --gutter: clamp(20px, 3.125vw, 40px); }
  html { scroll-behavior: smooth; scroll-padding-top: 24px; background: var(--bg); }
  body { background: var(--bg); color: var(--text); font-family: 'Kanit', sans-serif; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: clip; }
  ::selection { background: var(--accent); color: white; }
  :focus-visible { outline: 2px solid #93c5fd; outline-offset: 5px; }
  a, button { -webkit-tap-highlight-color: transparent; }
  a:hover, .main-nav button:hover, .footer nav button:hover { opacity: .7; }
  ::-webkit-scrollbar { width: 8px; }
  ::-webkit-scrollbar-track { background: var(--bg); }
  ::-webkit-scrollbar-thumb { background: #2a2a2e; border-radius: 4px; }
  .skip-link { position: fixed; top: 12px; left: 12px; z-index: 100; padding: 12px 20px; background: white; color: black; transform: translateY(-180%); }
  .skip-link:focus { transform: none; }
  .metallic { background: linear-gradient(180deg, #646973, #bbccd7); background-clip: text; -webkit-background-clip: text; color: transparent; }
}

@layer layout {
  .container { width: 100%; max-width: 1152px; margin-inline: auto; }
  .section-title { font-size: clamp(48px, 12vw, 160px); font-weight: 900; text-transform: uppercase; text-align: center; letter-spacing: -.05em; line-height: 1; }
  .hero { position: relative; min-height: 640px; height: min(100svh, 1000px); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; justify-items: center; isolation: isolate; padding-bottom: 32px; }
  .main-nav { position: relative; width: 100%; z-index: 3; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 24px var(--gutter) 0; text-transform: uppercase; letter-spacing: .05em; font-size: clamp(14px, 1.6vw, 22.4px); font-weight: 500; }
  .main-nav button { text-transform: inherit; letter-spacing: inherit; }
  .main-nav a, .main-nav button { min-height: 44px; display: inline-flex; align-items: center; }
  .hero-title { position: relative; grid-area: 2 / 1; align-self: start; z-index: 1; margin-top: 24px; width: 100%; font-size: 13.4vw; font-weight: 900; line-height: 1; letter-spacing: -.03em; text-transform: uppercase; text-align: center; white-space: nowrap; pointer-events: none; }
  .portrait-position { position: relative; grid-area: 2 / 1; align-self: center; justify-self: center; width: clamp(350px, 46vw, 620px); z-index: 2; pointer-events: none; }
  .portrait-magnet img { width: 100%; height: auto; max-height: 66svh; object-fit: contain; filter: drop-shadow(0 20px 50px #000c); }
  .hero-bottom { position: relative; z-index: 3; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 18px; padding: 0 var(--gutter); }
  .hero-bottom p { max-width: 440px; font-size: clamp(14px, 1.2vw, 18px); font-weight: 300; text-transform: uppercase; line-height: 1.5; letter-spacing: .025em; }
  .marquee { padding: 160px 0 40px; display: grid; gap: 12px; overflow: hidden; }
  .marquee-row { overflow: hidden; }
  .marquee-track, .marquee-set { display: flex; gap: 12px; width: max-content; }
  .marquee-track { transform: translateX(-500px); }
  .marquee-set img { flex: 0 0 420px; width: 420px; height: 270px; object-fit: cover; border: 1px solid #ffffff0d; border-radius: 16px; }
  .about { position: relative; min-height: 100svh; padding: 100px var(--gutter); display: grid; place-items: center; overflow: hidden; }
  .about-content { position: relative; z-index: 1; width: 100%; max-width: 896px; text-align: center; }
  .about-text { max-width: 560px; margin: 64px auto 96px; font-size: clamp(16px, 2vw, 21.6px); font-weight: 500; line-height: 1.625; }
  .word { display: inline-block; white-space: nowrap; }
  .character { display: inline-block; }
  .decoration { position: absolute; pointer-events: none; filter: drop-shadow(0 15px 30px #0009); }
  .decoration img { width: 100%; height: auto; }
  .decoration-1 { top: 4%; left: 4%; width: 210px; }
  .decoration-2 { bottom: 8%; left: 10%; width: 180px; }
  .decoration-3 { top: 4%; right: 4%; width: 210px; }
  .decoration-4 { bottom: 8%; right: 10%; width: 220px; }
  .services { position: relative; background: white; color: var(--bg); color-scheme: light; border-radius: 60px 60px 0 0; padding: 128px var(--gutter) 160px; }
  .services-container { max-width: 1024px; }
  .services .section-title { margin-bottom: 112px; }
  .service-list { border-top: 1px solid #0c0c0c26; }
  .service { display: grid; grid-template-columns: 180px minmax(0, 1fr); align-items: center; gap: 48px; border-bottom: 1px solid #0c0c0c26; padding: 48px 16px; border-radius: 12px; transition: background .3s; }
  .service:hover { background: #00000004; }
  .service-number { font-size: clamp(48px, 10vw, 140px); font-weight: 900; letter-spacing: -.06em; line-height: 1; }
  .service h3 { font-size: clamp(16px, 2.2vw, 33.6px); font-weight: 500; text-transform: uppercase; letter-spacing: .025em; line-height: 1.25; margin-bottom: 12px; }
  .service p { font-size: clamp(13.6px, 1.6vw, 20px); font-weight: 300; line-height: 1.625; color: #6e6e6e; }
  .projects { position: relative; z-index: 1; margin-top: -56px; padding: 128px var(--gutter) 64px; border-radius: 60px 60px 0 0; background: var(--bg); }
  .projects .section-title { margin-bottom: 112px; }
  .project-stack { padding-bottom: 0; }
  .project-slot { position: relative; padding: 24px 0; display: flex; align-items: flex-start; }
  .project-card { width: 100%; background: var(--bg); border: 2px solid var(--text); padding: 32px; border-radius: 60px; box-shadow: 0 25px 60px #000c; overflow: hidden; transform-origin: center top; }
  .project-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid #d7e2ea33; }
  .project-identity { display: flex; align-items: center; gap: 24px; min-width: 0; }
  .project-number { font-size: clamp(40px, 6vw, 72px); font-weight: 900; line-height: 1; letter-spacing: -.06em; }
  .project-category { display: block; font-size: 14px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: #d7e2ea99; }
  .project-header h3 { font-size: clamp(17.6px, 2.5vw, 35.2px); text-transform: uppercase; font-weight: 500; letter-spacing: .025em; overflow-wrap: anywhere; }
  .project-grid { display: grid; grid-template-columns: 5fr 7fr; grid-template-rows: minmax(0, 2fr) minmax(0, 3fr); height: clamp(230px, calc(100svh - 310px), 580px); gap: 24px; }
  .project-image { position: relative; display: block; overflow: hidden; border-radius: 44px; border: 1px solid #ffffff0d; background: #161618; min-width: 0; }
  .project-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
  .image-0 { grid-area: 1 / 1; }
  .image-1 { grid-area: 2 / 1; }
  .image-2 { grid-area: 1 / 2 / 3 / 3; }
  .project-image:hover img { transform: scale(1.05); }
  .image-hint { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 8px 16px; border: 1px solid #ffffff33; background: #0009; border-radius: 30px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; opacity: 0; transition: opacity .25s; width: max-content; max-width: 90%; }
  .project-image:hover .image-hint, .project-image:focus-visible .image-hint { opacity: 1; }
  .footer { position: relative; border-top: 1px solid #ffffff1a; padding: 64px var(--gutter) 48px; }
  .footer-cta { display: flex; justify-content: space-between; align-items: center; gap: 32px; padding-bottom: 48px; border-bottom: 1px solid #ffffff1a; }
  .footer h2 { font-size: clamp(30px, 3.75vw, 48px); font-weight: 900; line-height: 1.2; text-transform: uppercase; letter-spacing: -.025em; color: white; }
  .footer-description { max-width: 512px; font-weight: 300; margin-top: 8px; color: #d7e2eab3; }
  .footer-bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 32px; margin-top: 48px; }
  .footer-brand { font-size: 20px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; color: white; }
  .footer-caption { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: #d7e2ea80; margin-top: 4px; }
  .footer nav { display: flex; flex-wrap: wrap; align-items: center; gap: 28px; font-size: 14px; text-transform: uppercase; letter-spacing: .025em; }
}

@layer components {
  .button { min-height: 48px; padding: 14px 32px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px; font-size: 14px; line-height: 1.5; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; white-space: nowrap; transition: transform .25s, background .25s, border-color .25s; }
  .button:hover { transform: scale(1.04); opacity: 1; }
  .button:active { transform: scale(.96); }
  .button-contact { padding: 16px 48px; color: white; background: linear-gradient(123deg, #0b245c 7%, #2563eb 37%, #1d4ed8 72%, #38bdf8); box-shadow: 0 4px 4px #2563eb40, inset 4px 4px 12px #1d4ed8; outline: 2px solid white; outline-offset: -3px; font-size: 16px; }
  .button-contact:focus-visible { outline: 3px solid #93c5fd; outline-offset: 4px; }
  .button-outline { border: 1px solid #d7e2ea; }
  .button-outline:hover { background: #ffffff0d; }
  .back-top { padding: 8px 16px; min-height: 44px; font-size: 12px; border-color: #ffffff33; }
  .eyebrow { color: #fff; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
  body:has(dialog[open]) { overflow: hidden; }
  .dialog { margin: auto; color: var(--text); background: #121214; border: 1px solid #d7e2ea33; border-radius: 32px; width: calc(100% - 32px); max-height: calc(100svh - 32px); box-shadow: 0 25px 60px #000c; overscroll-behavior: contain; }
  .dialog::backdrop { background: #000d; backdrop-filter: blur(10px); }
  .contact-dialog { max-width: 576px; padding: 32px; }
  .close-dialog { position: absolute; right: 20px; top: 20px; width: 44px; height: 44px; font-size: 30px; font-weight: 300; line-height: 1; display: grid; place-items: center; border-radius: 50%; color: #ffffffb3; }
  .close-dialog:hover { background: #ffffff1a; color: white; }
  .contact-dialog > h2 { font-size: clamp(22px, 4vw, 30px); text-transform: uppercase; font-weight: 900; padding-right: 30px; line-height: 1.2; }
  .dialog-description { color: #d7e2eab3; font-size: 14px; margin: 8px 0 24px; }
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
  label { display: grid; gap: 6px; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: #d7e2eaab; }
  input, select, textarea { width: 100%; min-width: 0; color: white; background: #1a1a1e; border: 1px solid #ffffff1a; border-radius: 12px; padding: 11px 16px; font-size: 14px; text-transform: none; letter-spacing: normal; }
  textarea { resize: vertical; min-height: 100px; }
  input::placeholder, textarea::placeholder { color: #ffffff60; }
  .form-note { font-size: 13px; color: #d7e2eab3; margin: 16px 0; }
  .form-submit { width: 100%; font-size: 14px; }
  #form-status { font-size: 14px; margin-top: 12px; }
  .gallery-dialog { max-width: 1024px; overflow: auto; }
  .gallery-header { position: relative; padding: 16px 72px 16px 24px; border-bottom: 1px solid #ffffff1a; }
  .gallery-header h2 { font-size: 22px; text-transform: uppercase; line-height: 1.3; }
  .gallery-header .close-dialog { top: 14px; }
  .gallery-stage { position: relative; min-height: 280px; background: #000; display: grid; place-items: center; padding: 16px; }
  .gallery-stage img { max-height: 60svh; max-width: 100%; width: auto; height: auto; object-fit: contain; border-radius: 16px; }
  .gallery-arrow { position: absolute; top: 50%; transform: translateY(-50%); border-radius: 50%; background: #000b; border: 1px solid #ffffff40; height: 48px; width: 48px; font-size: 36px; line-height: 1; }
  .gallery-arrow:hover { background: #292929; }
  .previous { left: 16px; } .next { right: 16px; }
  .gallery-bottom { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding: 24px; border-top: 1px solid #ffffff1a; }
  .gallery-thumbnails { display: flex; gap: 12px; }
  .gallery-thumbnails button { width: 72px; height: 52px; border-radius: 12px; overflow: hidden; border: 2px solid transparent; opacity: .6; }
  .gallery-thumbnails button[aria-current="true"] { border-color: var(--accent); opacity: 1; }
  .gallery-thumbnails img { width: 100%; height: 100%; object-fit: cover; }
  #gallery-count { font-size: 12px; color: #d7e2ea99; }
  .gallery-bottom .button { font-size: 12px; padding: 12px 20px; }
}

@layer responsive {
  @media (max-width: 1023px) {
    .hero-title { font-size: 13.4vw; }
    .decoration-1, .decoration-3 { width: 160px; }
    .decoration-2 { width: 140px; left: 6%; } .decoration-4 { width: 170px; right: 6%; }
    .service { grid-template-columns: 140px minmax(0,1fr); }
    .project-header h3 { font-size: 25px; }
  }
  @media (max-width: 767px) {
    .hero { grid-template-rows: auto auto auto auto; gap: 14px; height: auto; min-height: 0; padding-bottom: max(28px, env(safe-area-inset-bottom)); }
    .main-nav { padding-top: max(16px, env(safe-area-inset-top)); gap: 10px; font-size: clamp(12px, 3vw, 16px); }
    .hero-title { grid-area: 2 / 1; font-size: 13.4vw; margin: 4px 0 0; align-self: start; }
    .portrait-position { grid-area: 3 / 1; width: min(92vw, 440px); margin-top: -6px; }
    .portrait-magnet img { max-height: 58svh; width: 100%; height: auto; }
    .hero-bottom { grid-area: 4 / 1; padding: 0 var(--gutter); align-items: center; gap: 16px; }
    .hero-bottom p { max-width: 360px; font-size: 14px; line-height: 1.5; }
    .button-contact { padding: 14px 32px; font-size: 14px; }
    .marquee { padding-top: 56px; padding-bottom: 24px; }
    .about { min-height: 0; padding-block: 148px; }
    .about-content { max-width: 620px; }
    .about-text { margin: 56px auto 80px; }
    .decoration-1, .decoration-3 { width: 120px; top: 2%; }
    .decoration-2 { width: 100px; bottom: 3%; left: 3%; }
    .decoration-4 { width: 130px; bottom: 3%; right: 3%; }
    .services { border-radius: 40px 40px 0 0; padding: 80px var(--gutter) 120px; }
    .services .section-title, .projects .section-title { margin-bottom: 64px; }
    .service { grid-template-columns: 1fr; gap: 16px; padding: 32px 8px; }
    .service h3 { margin-bottom: 8px; }
    .projects { border-radius: 40px 40px 0 0; margin-top: -40px; padding: 80px var(--gutter) 32px; }
    .project-stack { padding-bottom: 0; }
    .project-slot { position: relative; top: auto; min-height: 0; padding-block: 24px; }
    .project-card { border-radius: 28px; padding: 20px; }
    .project-identity { gap: 16px; }
    .project-header h3 { font-size: clamp(17px, 4vw, 24px); }
    .project-grid { height: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto auto; gap: 12px; }
    .project-image { border-radius: 18px; }
    .image-0 { grid-area: 2 / 1; aspect-ratio: 1; }
    .image-1 { grid-area: 2 / 2; aspect-ratio: 1; }
    .image-2 { grid-area: 1 / 1 / 2 / 3; aspect-ratio: 16 / 10; }
    .project-category { font-size: 12px; }
    .project-header .button { padding: 12px 24px; font-size: 12px; }
    .footer-cta { align-items: flex-start; flex-direction: column; gap: 24px; }
    .footer nav { gap: 24px; }
  }
  @media (max-width: 639px) {
    .hero { gap: 14px; min-height: 0; }
    .hero-title { font-size: 13.4vw; margin-top: 8px; }
    .portrait-position { width: min(96vw, 420px); }
    .portrait-magnet img { max-height: 56svh; }
    .hero-bottom { flex-direction: column; align-items: center; gap: 16px; }
    .hero-bottom p { max-width: 340px; font-size: 14px; line-height: 1.5; }
    .hero-bottom .button-contact { padding: 14px 32px; min-height: 50px; font-size: 13px; }
    .marquee { padding-top: 40px; }
    .marquee-set img { flex-basis: 300px; width: 300px; height: 200px; }
    .about-text { margin: 32px auto 40px; font-size: 17px; line-height: 1.7; }
    .decoration-1 { left: 8px; top: 20px; width: 88px; } .decoration-3 { right: 8px; top: 20px; width: 88px; }
    .decoration-2 { bottom: 16px; width: 72px; } .decoration-4 { bottom: 16px; width: 94px; }
    .services { padding-top: 64px; }
    .services .section-title, .projects .section-title { margin-bottom: 40px; }
    .service { grid-template-columns: 52px minmax(0, 1fr); align-items: start; gap: 16px; padding: 28px 0; }
    .service-number { font-size: 46px; }
    .service h3 { font-size: 20px; }
    .service p { font-size: 15px; line-height: 1.65; }
    .project-header { gap: 16px; padding-bottom: 18px; margin-bottom: 18px; }
    .project-identity { gap: 12px; }
    .project-header .button { min-height: 44px; }
    .footer-bottom { align-items: flex-start; flex-direction: column; }
    .footer-description { font-size: 14px; }
    .footer nav { font-size: 12px; }
    .contact-dialog { padding: 24px; }
    .form-grid { grid-template-columns: 1fr; }
    .gallery-bottom { padding: 16px; }
    .gallery-thumbnails button { width: 60px; height: 44px; }
    .gallery-header h2 { font-size: 18px; }
  }
  .project-stack .project-slot:last-child { min-height: 0; margin-bottom: 0; }
  .project-stack.is-pinned { position: relative; overflow: clip; }
  .project-stack.is-pinned .project-slot { position: absolute; inset: 0; display: block; padding: 0; margin: 0; min-height: 0; z-index: calc(var(--card-index) + 1); }
  .project-stack.is-pinned .project-card { position: relative; top: calc(var(--card-index) * 20px); }
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  }
}
