/* =============================================================
   luiswo.dev — global shell (editorial / swiss)
   Per-project pages may load an additional style.css that overrides
   .project-content scope freely. Keep this file additive/global.
   ============================================================= */

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, h5, h6, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg, video { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---------- design tokens ---------- */
:root {
  --bg: #faf9f5;
  --bg-2: #f1efe6;
  --fg: #111110;
  --muted: #6a6a64;
  --rule: #11111014;
  --accent: #ff5b1f;
  --accent-fg: #ffffff;

  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, ui-serif, serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --pad-x: clamp(1.25rem, 4vw, 4rem);
  --pad-y: clamp(2rem, 6vw, 5rem);
  --max: 1400px;

  --t: cubic-bezier(.2,.7,.2,1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0e;
    --bg-2: #18181614;
    --fg: #f3f1e8;
    --muted: #9c9a90;
    --rule: #ffffff14;
    --accent: #ff7d3a;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f0e;
  --bg-2: #18181614;
  --fg: #f3f1e8;
  --muted: #9c9a90;
  --rule: #ffffff14;
  --accent: #ff7d3a;
}

::selection { background: var(--accent); color: var(--accent-fg); }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: clamp(15px, 1vw + 0.6rem, 18px);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem var(--pad-x);
  border-bottom: 1px solid var(--rule);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
}
.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  font-style: italic;
  display: flex;
  align-items: center;
}
.brand svg {
  height: 1.75rem;
  width: auto;
}

.lw-fg { stroke: var(--fg); fill: var(--fg); }
.site-nav { display: flex; align-items: center; gap: 1.4rem; }
.site-nav a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  padding: 0.4rem 0;
  border-bottom: 1px solid transparent;
  transition: border-color 200ms var(--t), color 200ms var(--t);
}
.site-nav a:hover { border-color: var(--fg); }

#theme-toggle {
  width: 1.9rem; height: 1.9rem;
  display: inline-grid; place-items: center;
  border: 1px solid var(--rule);
  border-radius: 999px;
  transition: border-color 200ms var(--t), background 200ms var(--t);
}
#theme-toggle:hover { border-color: var(--fg); }
#theme-toggle .theme-icon {
  width: 0.85rem; height: 0.85rem; border-radius: 999px;
  background: var(--fg);
  box-shadow: inset 0.4rem -0.1rem 0 0 var(--bg);
  transition: transform 300ms var(--t), box-shadow 300ms var(--t);
}
:root[data-theme="dark"] #theme-toggle .theme-icon,
:root:not([data-theme="light"]) #theme-toggle .theme-icon {
  /* no-op; handled by var swap */
}

/* ---------- hero ---------- */
.hero {
  padding: clamp(3rem, 10vw, 7rem) var(--pad-x) clamp(2rem, 5vw, 3rem);
  border-bottom: 1px solid var(--rule);
  position: relative;
  overflow: hidden;
}
.hero-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  font-size: clamp(3rem, 13vw, 12rem);
  line-height: 0.88;
  letter-spacing: -0.04em;
  margin: 0;
  display: flex; flex-direction: column;
}
.hero-name-1 { display: block; }
.hero-name-2 {
  display: block;
  text-indent: clamp(1rem, 6vw, 6rem);
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "opsz" 144, "SOFT" 100;
}
.hero-name-1 em, .hero-name-2 em {
  color: var(--accent);
  font-style: italic;
}

.hero-sub {
  margin-top: clamp(1.4rem, 3vw, 2.4rem);
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2vw, 1.6rem);
  color: var(--muted);
  max-width: 50ch;
  font-style: italic;
  font-weight: 350;
}

.hero-cta {
  position: absolute;
  right: var(--pad-x);
  bottom: clamp(1rem, 3vw, 2rem);
  display: inline-flex; align-items: center; gap: 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero-cta-line {
  width: 3rem; height: 1px; background: currentColor;
  display: inline-block;
  position: relative;
  overflow: hidden;
}
.hero-cta-line::after {
  content: ""; position: absolute; inset: 0;
  background: var(--accent);
  transform: translateX(-100%);
  animation: line-slide 2s ease-in-out infinite;
}
@keyframes line-slide {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(0); }
  100% { transform: translateX(100%); }
}

/* ---------- shared label ---------- */
.label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- about ---------- */
.about {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  padding: clamp(3rem, 8vw, 6rem) var(--pad-x);
  border-bottom: 1px solid var(--rule);
}
@media (min-width: 720px) {
  .about {
    grid-template-columns: 14rem 1fr;
    gap: clamp(2rem, 6vw, 5rem);
  }
}
.about-prose {
  font-family: var(--font-display);
  font-weight: 350;
  font-size: clamp(1.3rem, 2.2vw, 2rem);
  line-height: 1.35;
  letter-spacing: -0.01em;
  max-width: 38ch;
}
.about-prose p + p { margin-top: 1.4rem; }
.about-prose strong {
  font-weight: 600;
  font-style: italic;
  color: var(--fg);
}
.about-prose em {
  color: var(--accent);
  font-style: italic;
}
.about-prose a {
  color: var(--accent);
  text-decoration: none;
  position: relative;
  display: inline-block;
  padding-bottom: 0.2rem;

  /* The animated wavy underline */
  &::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6px; /* Adjust height of the wave container */
    background-color: var(--accent);

    /* SVG mask for a repeating wave shape */
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 4'%3E%3Cpath d='M0,2 Q5,0 10,2 T20,2' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 4'%3E%3Cpath d='M0,2 Q5,0 10,2 T20,2' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E");
    -webkit-mask-size: 20px 6px;
    mask-size: 20px 6px;
    -webkit-mask-repeat: repeat-x;
    mask-repeat: repeat-x;

    /* Wave motion animation */
    animation: wave-move 1s linear infinite;
  }
  
  &:hover {
    animation-play-state: paused; /* Pause wave animation on hover for better readability */
  }
}

/* Animate the horizontal position of the mask */
@keyframes wave-move {
  0% {
    -webkit-mask-position-x: 0px;
    mask-position-x: 0px;
  }
  100% {
    /* Matches the mask-size width (20px) for a seamless loop */
    -webkit-mask-position-x: 20px;
    mask-position-x: 20px;
  }
}

/* ---------- gallery ---------- */
.gallery {
  padding: clamp(3rem, 8vw, 6rem) var(--pad-x) clamp(4rem, 10vw, 8rem);
}
.gallery-header { margin-bottom: clamp(2rem, 5vw, 4rem); display: grid; gap: 1rem; }
.gallery-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2rem, 6vw, 4.5rem);
  line-height: 1;
  letter-spacing: -0.03em;
  max-width: 18ch;
}
.gallery-title em { color: var(--accent); font-weight: 400; }
.gallery-sub { color: var(--muted); font-family: var(--font-display); font-style: italic; }

.cards { display: flex; flex-direction: column; border-top: 1px solid var(--rule); }
.card {
  --accent: #111110;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: clamp(1rem, 3vw, 2.5rem);
  padding: clamp(1.5rem, 3.5vw, 2.5rem) 0;
  border-bottom: 1px solid var(--rule);
  position: relative;
  transition: color 250ms var(--t);
  isolation: isolate;
}
.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 400ms var(--t);
  z-index: -1;
}
.card:hover::before { transform: scaleY(1); }
.card:hover .card-arrow { transform: translateY(0.3rem); color: var(--accent); }
.card:hover .card-title { color: var(--accent); }

.card-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  align-self: start;
  padding-top: 0.6rem;
  padding-left: 2rem;
}
.card-body { display: grid; gap: 0.6rem; }
.card-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.6rem, 4vw, 3rem);
  line-height: 1;
  letter-spacing: -0.03em;
  transition: color 250ms var(--t);
  display: flex; align-items: center; gap: 1rem;

  > img {
    width: 2.5rem; height: 2.5rem;
    object-fit: contain;
    pointer-events: none;
    flex-shrink: 0;
  }

  > span {
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
  }
}
.card-title > img.logo-dark,
.ps-title > img.logo-dark  { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card-title > img.logo-light,
  :root:not([data-theme="light"]) .ps-title  > img.logo-light { display: none; }
  :root:not([data-theme="light"]) .card-title > img.logo-dark,
  :root:not([data-theme="light"]) .ps-title  > img.logo-dark  { display: block; }
}
:root[data-theme="dark"] .card-title > img.logo-light,
:root[data-theme="dark"] .ps-title  > img.logo-light { display: none; }
:root[data-theme="dark"] .card-title > img.logo-dark,
:root[data-theme="dark"] .ps-title  > img.logo-dark  { display: block; }
.card.is-featured .card-title::after {
  content: " ★";
  color: var(--accent);
  font-size: 0.5em;
  vertical-align: super;
  margin-left: 0.3em;
}
.card-summary {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--muted);
  max-width: 56ch;
  font-size: clamp(1rem, 1.4vw, 1.15rem);
}
.card-meta {
  display: flex; gap: 1.2rem; flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status { padding: 0.1rem 0.5rem; border: 1px solid var(--rule); border-radius: 999px; }
.status-shipped { color: var(--accent); border-color: currentColor; }
.status-wip { color: #d6a900; border-color: currentColor; }
.status-archived { color: var(--muted); }

.card-arrow {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  align-self: start;
  padding-top: 0.5rem;
  transition: transform 300ms var(--t), color 250ms var(--t);
  color: var(--muted);
}

.empty {
  padding: 3rem 0;
  font-family: var(--font-display);
  font-style: italic;
  color: var(--muted);
}
.empty code {
  font-family: var(--font-mono);
  background: var(--bg-2);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

/* ---------- tags / links ---------- */
.tags, .links { display: flex; flex-wrap: wrap; gap: 0.4rem 0.6rem; padding: 0; }
.tags li {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
}
.links li a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  border-bottom: 1px solid currentColor;
  padding-bottom: 0.1rem;
}

/* ---------- project sections (inline on main page) ---------- */
.project-section {
  border-top: 4px solid var(--accent);
  padding: clamp(3rem, 8vw, 6rem) var(--pad-x) clamp(4rem, 10vw, 7rem);
  scroll-margin-top: 4.5rem;
  position: relative;
}

.ps-inner {
  display: grid;
  gap: clamp(2rem, 5vw, 4rem);
  max-width: var(--max);
  margin: 0 auto;
}
@media (min-width: 900px) {
  .ps-inner {
    grid-template-columns: 1fr 1.6fr;
    align-items: start;
  }
}

.ps-header { display: grid; gap: 1rem; min-width: 0; container-type: inline-size; }

.ps-num {
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.ps-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.5rem, 8cqi, 4.5rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  display: flex; align-items: center; gap: 1rem;
  white-space: nowrap;

  > img {
    width: 3.5rem; height: 3.5rem;
    object-fit: contain;
    pointer-events: none;
    flex-shrink: 0;
  }

  > span { min-width: 0; }
}

.ps-summary {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  color: var(--muted);
  max-width: 36ch;
}

.ps-meta { display: grid; gap: 0.8rem; padding-top: 0.5rem; }
.ps-meta-line { color: var(--muted); }

.ps-body {
  font-size: 1.05rem;
  line-height: 1.72;
}
.ps-body h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.5rem, 2.8vw, 2rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 2.4rem 0 0.9rem;
}
.ps-body h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.3rem;
  margin: 1.8rem 0 0.5rem;
}
.ps-body p { margin: 0 0 1.2rem; }
.ps-body a { color: var(--accent); border-bottom: 1px solid currentColor; }
.ps-body ul, .ps-body ol { margin: 0 0 1.2rem 1.4rem; padding-left: 0; }
.ps-body ul li { list-style: disc; }
.ps-body ol li { list-style: decimal; }
.ps-body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: color-mix(in oklab, var(--accent) 10%, var(--bg));
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}
.ps-body pre {
  font-family: var(--font-mono);
  background: color-mix(in oklab, var(--accent) 8%, var(--bg));
  border-left: 3px solid var(--accent);
  padding: 1rem 1.2rem;
  border-radius: 0 8px 8px 0;
  overflow-x: auto;
  margin: 0 0 1.4rem;
  font-size: 0.87rem;
  line-height: 1.55;
}
.ps-body pre code { background: none; padding: 0; }
.ps-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  color: var(--muted);
  font-style: italic;
  margin: 0 0 1.4rem;
}
.ps-body img { border-radius: 8px; margin: 1.5rem 0; max-width: 100%; }

.ps-back {
  position: absolute;
  bottom: clamp(1.2rem, 2vw, 2rem);
  right: var(--pad-x);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px dashed var(--rule);
  padding-bottom: 0.1rem;
  transition: color 200ms var(--t), border-color 200ms var(--t);
}
.ps-back:hover { color: var(--accent); border-color: currentColor; }

/* ---------- 404 ---------- */
@keyframes fof-rise {
  from { opacity: 0; transform: translateY(1.4rem); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fof-glitch-1 {
  0%, 90%, 100% { transform: skewX(0); clip-path: none; }
  91% { transform: skewX(-8deg); clip-path: inset(0 0 55% 0); color: var(--accent); }
  92% { transform: skewX(5deg);  clip-path: inset(45% 0 0 0); }
  93% { transform: skewX(-2deg); clip-path: inset(20% 0 30% 0); }
  94% { transform: skewX(0); clip-path: none; color: inherit; }
}
@keyframes fof-glitch-2 {
  0%, 88%, 100% { transform: translateX(0); clip-path: none; }
  89% { transform: translateX(-4px); clip-path: inset(10% 0 60% 0); }
  90% { transform: translateX(3px);  clip-path: inset(55% 0 5% 0); color: var(--accent); }
  91% { transform: translateX(-2px); clip-path: inset(30% 0 40% 0); }
  92% { transform: translateX(0); clip-path: none; color: inherit; }
}
@keyframes fof-glitch-3 {
  0%, 85%, 100% { opacity: 1; transform: scaleX(1); }
  86% { opacity: 0.15; transform: scaleX(1.04); }
  87% { opacity: 1;    transform: scaleX(0.97); color: var(--accent); }
  88% { opacity: 0.4;  transform: scaleX(1.02); }
  89% { opacity: 1;    transform: scaleX(1); color: inherit; }
}
@media (prefers-reduced-motion: reduce) {
  @keyframes fof-rise     { from { opacity: 0; } to { opacity: 1; } }
  @keyframes fof-glitch-1 { 0%, 100% { transform: none; } }
  @keyframes fof-glitch-2 { 0%, 100% { transform: none; } }
  @keyframes fof-glitch-3 { 0%, 100% { transform: none; } }
}

.page-404 main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.four-oh-four {
  padding: clamp(1.5rem, 4vh, 3rem) var(--pad-x);
  display: grid; justify-items: center; gap: 1.2rem;
  text-align: center;
}
.fof-item {
  opacity: 0;
  animation: fof-rise 0.55s var(--t) forwards;
}
.fof-item:nth-child(1) { animation-delay: 0.05s; }
.fof-item:nth-child(2) { animation-delay: 0.15s; }
.fof-item:nth-child(3) { animation-delay: 0.25s; }
.fof-item:nth-child(4) { animation-delay: 0.32s; }
.fof-item:nth-child(5) { animation-delay: 0.38s; }

.fof-num {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(5rem, 18vw, 13rem);
  line-height: 0.88;
  letter-spacing: -0.04em;
  color: var(--fg);
}
.fof-d1 { display: inline-block; animation: fof-glitch-1 7s 0.8s infinite; }
.fof-d2 { display: inline-block; animation: fof-glitch-2 6s 1.2s infinite; color: var(--accent); }
.fof-d3 { display: inline-block; animation: fof-glitch-3 5s 2.1s infinite; }
.fof-msg {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.fof-msg code {
  font-family: inherit;
  color: var(--fg);
}
.fof-hint {
  color: var(--muted);
  font-size: 0.9em;
}
.link-underline {
  color: var(--accent);
  border-bottom: 1px solid currentColor;
  padding-bottom: 0.1rem;
}

/* ---------- footer ---------- */
.site-footer {
  margin-top: auto;
  padding: 2rem var(--pad-x);
  border-top: 1px solid var(--rule);
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-align: center;
}
@media (min-width: 640px) {
  .site-footer {
    flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 1.2rem;
    > * { flex: 1 }
    > :last-child:not(:first-child) { text-align: right; }
  }
}
.site-footer a { border-bottom: 1px dashed var(--rule); padding-bottom: 0.1rem; }
.site-footer a:hover { color: var(--accent); border-color: currentColor; }
.social-links { 
  list-style: none; margin: 0; padding: 0; display: flex; gap: .6rem;
  justify-content: center;
  > li a {
    color: var(--muted);
    border-bottom: 1px dashed var(--rule);
    padding-bottom: 0.1rem;
    transition: color 500ms var(--t), border-color 500ms var(--t);
  }
  > li:not(:last-child)::after {
    content: "•";
    color: var(--muted);
    margin-left: .6rem;
  }
}

/* ---------- focus ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------- view transitions ---------- */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 350ms;
  animation-timing-function: cubic-bezier(.2,.7,.2,1);
}
