/* ============================================
   LORE STUDIO
   ============================================ */

@font-face {
  font-family: 'Suisse Intl';
  src: url('/fonts/SuisseIntl-Regular-WebS.woff2') format('woff2'),
       url('/fonts/SuisseIntl-Regular-WebS.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: optional;
}

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

:root {
  /* Brand Colors */
  --color-dark-grey: #141414;
  --color-warm-off-white: #e5e4df;

  /* Semantic Colors - Dark mode (default) */
  --color-bg: var(--color-dark-grey);
  --color-bg-hover: rgba(255, 255, 255, 0.05);
  --color-text: var(--color-warm-off-white);
  --color-border: rgba(255, 255, 255, 0.1);

  /* Typography */
  --font-family: 'Suisse Intl', 'Helvetica Neue', Helvetica, Arial, sans-serif;

  /* Spacing */
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 3rem;
  --space-xl: 6rem;
  --space-2xl: 10rem;

  /* Layout */
  --hero-vertical-offset: 35vh;

  /* Opacity */
  --opacity-muted: 0.5;
  --opacity-subtle: 0.6;

  /* Transitions */
  --duration-fast: 0.2s;
  --duration-normal: 0.3s;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light mode */
@media (prefers-color-scheme: light) {
  :root {
    --color-bg: var(--color-warm-off-white);
    --color-bg-hover: rgba(20, 20, 20, 0.05);
    --color-text: var(--color-dark-grey);
    --color-border: rgba(20, 20, 20, 0.1);
  }
}

html {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Text wrapping */
h1, h2, h3, h4, h5, h6,
.hero-title, .brand-name {
  text-wrap: balance;
}

p, .origin-statement, .brand-desc {
  text-wrap: pretty;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

/* Nav gradient fade */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(
    to bottom,
    var(--color-bg) 0%,
    color-mix(in srgb, var(--color-bg) 60%, transparent) 50%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 99;
}

::selection {
  background-color: var(--color-text);
  color: var(--color-bg);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.ui-text {
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1rem;
  text-transform: uppercase;
}

/* ============================================
   NAVIGATION
   ============================================ */

.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-bg);
  padding: var(--space-sm) var(--space-md);
  z-index: 200;
  transition: top 0.2s;
}

.skip-link:focus {
  top: var(--space-sm);
}

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
}

.nav-logo img {
  height: 16px;
  width: auto;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.nav-link,
.footer-link {
  opacity: var(--opacity-subtle);
  transition: opacity var(--duration-fast);
}

.nav-link:hover,
.footer-link:hover {
  opacity: 1;
}

/* Logo theme switching */
.logo-light { display: block; }
.logo-dark { display: none; }

@media (prefers-color-scheme: light) {
  .logo-light { display: none; }
  .logo-dark { display: block; }
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg);
}

.footer-copyright {
  opacity: var(--opacity-muted);
}

.footer-nav {
  display: flex;
  gap: var(--space-md);
}

/* ============================================
   HERO (shared)
   ============================================ */

.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
}

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-label {
  letter-spacing: 0.2em;
}

.hero-title {
  font-weight: 400;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

/* ============================================
   HOME PAGE
   ============================================ */

/* Home hero */
.hero:not(.story-page .hero):not(.error-page .hero) {
  justify-content: center;
  overflow: hidden;
}

.hero:not(.story-page .hero):not(.error-page .hero) .hero-content {
  flex: 1;
  justify-content: center;
}

.hero:not(.story-page .hero):not(.error-page .hero) .hero-title {
  font-size: clamp(2.5rem, 10vw, 8rem);
  line-height: 0.95;
  display: flex;
  flex-direction: column;
  gap: 0.1em;
}

.title-line {
  display: block;
  overflow: hidden;
}

.title-word {
  display: inline-block;
}

/* Origin section */
.origin {
  padding: var(--space-2xl) var(--space-lg);
}

.origin-content {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

.origin-statement {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: var(--space-xl);
  text-transform: uppercase;
}

/* Portfolio grid */
.portfolio {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.brand-item {
  padding: var(--space-xl) var(--space-lg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  min-height: 400px;
  transition: background 0.3s;
}

.brand-item:nth-child(2n) {
  border-right: none;
}

.brand-item:nth-last-child(n+3) {
  border-bottom: 1px solid var(--color-border);
}

.brand-item:hover {
  background: var(--color-bg-hover);
}

.brand-item--intro {
  justify-content: center;
}

.brand-item--intro .brand-name {
  margin-top: 0;
}

.brand-item--intro .brand-desc {
  max-width: 400px;
}

.brand-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: auto;
}

.brand-category,
.brand-number {
  opacity: var(--opacity-muted);
}

.brand-name {
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: var(--space-lg) 0 var(--space-md);
  text-transform: uppercase;
}

.brand-desc {
  font-size: 0.875rem;
  line-height: 1.5;
  opacity: var(--opacity-subtle);
  max-width: 300px;
  margin-bottom: var(--space-lg);
}

.brand-cta {
  margin-top: auto;
  opacity: var(--opacity-muted);
  transition: opacity var(--duration-fast);
}

.brand-item:hover .brand-cta {
  opacity: 1;
}

.brand-item:not(.brand-item--intro) .brand-name {
  transition: transform 0.4s var(--ease-out-expo);
}

.brand-item:not(.brand-item--intro):hover .brand-name {
  transform: translateX(10px);
}

/* ============================================
   STORY PAGE
   ============================================ */

/* Story page hero */
.story-page .hero {
  justify-content: center;
  overflow: hidden;
}

.story-page .hero-content {
  flex: 1;
  justify-content: center;
}

.story-page .hero-title {
  font-size: clamp(2.5rem, 10vw, 8rem);
  line-height: 0.95;
  display: flex;
  flex-direction: column;
  gap: 0.1em;
}

.story-page .hero-label {
  margin-bottom: var(--space-lg);
}

/* Alternating sections */
.story-section-alt {
  min-height: 50vh;
}

.story-section-alt .hero-title {
  font-size: clamp(2rem, 8vw, 6rem);
}

/* ============================================
   404 PAGE
   ============================================ */

.error-page .hero {
  justify-content: center;
}

.error-page .hero-title {
  font-size: clamp(2.5rem, 8vw, 5rem);
  margin-bottom: var(--space-md);
}

.error-page .hero-text {
  font-size: 1rem;
  margin-bottom: var(--space-lg);
}

.error-page .hero-link {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  transition: background 0.2s;
}

.error-page .hero-link:hover {
  background: var(--color-bg-hover);
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUpSmall {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInFromTop {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes titleReveal {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes labelFadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 0.5; transform: translateY(0); }
}

@keyframes wordReveal {
  from { opacity: 0.2; }
  to { opacity: 1; }
}

/* Navigation */
body.initial-load .nav {
  animation: slideInFromTop 0.8s var(--ease-out-expo) 0.1s forwards;
}

/* Hero title */
.title-word {
  opacity: 0;
  transform: translateY(100%);
}

body.page-loaded .title-word {
  animation: titleReveal 1.2s var(--ease-out-expo) forwards;
}

body.page-loaded .title-line:nth-child(1) .title-word { animation-delay: 0.3s; }
body.page-loaded .title-line:nth-child(2) .title-word { animation-delay: 0.45s; }
body.page-loaded .title-line:nth-child(3) .title-word { animation-delay: 0.6s; }

/* Scroll-triggered elements */
[data-animate] {
  opacity: 0;
  transform: translateY(60px);
  transition: opacity 1s var(--ease-out-expo), transform 1s var(--ease-out-expo);
}

[data-animate].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Brand cards */
[data-brand] {
  opacity: 0;
  transform: translateY(40px);
  transition:
    opacity 0.8s var(--ease-out-expo),
    transform 0.8s var(--ease-out-expo),
    background 0.3s ease;
  transition-delay: var(--stagger-delay, 0s);
}

[data-brand].is-visible {
  opacity: 1;
  transform: translateY(0);
  transition: background 0.3s ease;
  transition-delay: 0s;
}

/* Word reveal - scroll-driven */
.reveal-text .word,
.origin-statement .word,
.story-text .word {
  opacity: 0.2;
  display: inline-block;
  margin-right: 0.25em;
  animation: wordReveal linear both;
  animation-timeline: view(block);
  animation-range: entry 0% cover 35%;
}

/* Fallback for browsers without scroll-timeline */
@supports not (animation-timeline: view()) {
  .reveal-text .word,
  .origin-statement .word,
  .story-text .word {
    animation: none;
    transition: opacity 0.4s ease;
  }

  .reveal-text.is-revealing .word {
    animation: wordFadeIn 0.5s ease forwards;
    animation-delay: calc(var(--word-index, 0) * 0.03s);
  }

  @keyframes wordFadeIn {
    from { opacity: 0.2; }
    to { opacity: 1; }
  }
}

/* Story page animations */
.story-page .hero-label {
  opacity: 0;
  transform: translateY(15px);
}

body.page-loaded .story-page .hero-label {
  animation: labelFadeIn 0.7s var(--ease-out-expo) 0.1s forwards;
}

/* Alternating section animations */
.story-section-alt .hero-label,
.story-section-alt .title-word {
  opacity: 0;
}

.story-section-alt .title-word {
  transform: translateY(100%);
}

.story-section-alt.is-visible .hero-label {
  animation: labelFadeIn 0.7s var(--ease-out-expo) forwards;
}

.story-section-alt.is-visible .title-word {
  animation: titleReveal 1.2s var(--ease-out-expo) forwards;
}

/* 404 page initial states */
.error-page .hero-label,
.error-page .hero-title,
.error-page .hero-text,
.error-page .hero-link {
  opacity: 0;
}

body.page-loaded .error-page .hero-label {
  animation: labelFadeIn 0.7s var(--ease-out-expo) 0.1s forwards;
}

body.page-loaded .error-page .hero-title {
  animation: fadeInUp 0.9s var(--ease-out-expo) 0.2s forwards;
}

body.page-loaded .error-page .hero-text {
  animation: fadeInUpSmall 0.7s var(--ease-out-expo) 0.4s forwards;
}

body.page-loaded .error-page .hero-link {
  animation: fadeInUpSmall 0.6s var(--ease-out-expo) 0.5s forwards;
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .title-word,
  [data-animate],
  [data-brand],
  .reveal-text .word,
  .story-page .hero-label,
  .story-section-alt .title-word,
  .error-page .hero-label,
  .error-page .hero-title,
  .error-page .hero-text,
  .error-page .hero-link {
    opacity: 1 !important;
    transform: none !important;
  }

  .story-page .hero-label,
  .error-page .hero-label {
    opacity: 0.5 !important;
  }
}

/* ============================================
   RESPONSIVE
   ============================================ */

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

  .brand-item {
    border-right: none;
  }
}

@media (max-width: 768px) {
  .nav,
  .hero,
  .brand-item,
  .footer {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }

  .brand-item {
    min-height: 300px;
  }

  .footer {
    flex-direction: column;
    gap: var(--space-md);
    text-align: center;
  }
}
