/* feihei.github.io homepage styles
   Visual identity: dark green #002a13 + white + rounded cards. Don't redesign without asking.
   Layout: slide-deck style — one .slide per viewport, CSS scroll-snap, dots built by js/main.js. */

:root{
  --color-bg: #002a13;
  --color-bg-raised: #0a3d20;
  --color-ink: #fff;
  --color-ink-dim: rgba(255, 255, 255, 0.78);
  --radius-card: 1.5em;
  --shadow-card: 0 3px 12px rgba(0, 0, 0, 0.22);
  --shadow-card-hover: 0 10px 26px rgba(0, 0, 0, 0.35);
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

html, body{
  height: 100%;
}

body{
  text-align: center;
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  /* Subtle depth: slightly lighter glow at the top, flat identity green below */
  background-image: radial-gradient(120% 90% at 50% 0%, var(--color-bg-raised), var(--color-bg) 60%);
  background-attachment: fixed;
  color: var(--color-ink);
  margin: 0;
  padding: 0;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
a{
  text-decoration: none;
  color: var(--color-ink);
}

/* Language switch bar */
.language-switch {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 42, 19, 0.8);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: 12px 0;
  z-index: 1000;
  border-bottom: 1px solid rgba(255, 255, 255, 0.9);
}

.language-option {
  appearance: none;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  padding: 8px 15px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 20px;
}

.language-option.active {
  background-color: var(--color-ink);
  color: var(--color-bg);
}

.language-option:focus-visible,
.language-icon:focus-visible,
.slide-dot:focus-visible {
  outline: 2px solid var(--color-ink);
  outline-offset: 2px;
}

.language-icon {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  width: 40px;
  height: 40px;
  margin: 0 20px;
  cursor: pointer;
  transition: transform 0.6s ease;
}

.language-icon.flipped {
  transform: scaleX(-1);
}

.language-icon svg {
  width: 100%;
  height: 100%;
}

/* Slide navigation dots */
#slide-nav{
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1001;
}

.slide-dot{
  appearance: none;
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--color-ink);
  background: transparent;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.3s ease;
}

.slide-dot.active{
  background: var(--color-ink);
  transform: scale(1.25);
}

/* Content sections: the active one is the slide scroller.
   No fade-in on load — everything is visible from the first paint.
   Language switches cross-fade via the View Transition API (js/main.js). */
.content-section {
  display: none;
}

.content-section.active {
  display: block;
  height: 100dvh;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
}

/* One slide = one viewport */
.slide{
  min-height: 100dvh;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 90px 6vw 50px;
  box-sizing: border-box;
}

/* Intro slide */
.slide-intro .title{
  width: auto;
  max-width: 90%;
  padding: 0;
  font-size: clamp(1.3em, 3.2vw, 1.8em);
}
#huge{
  line-height: 0em;
  font-size: clamp(2.4em, 8vw, 3.8em);
  letter-spacing: 0.03em;
}
#left{
  text-align: left;
}
#right{
  text-align: right;
}

/* Book-like intro: left-aligned paragraph with a drop cap on its first letter */
.slide-intro .intro{
  margin: 1.6em auto 0;
  text-align: left;
  font-size: clamp(1em, 2vw, 1.2em);
  max-width: 36em;
}
.slide-intro .intro p::first-letter{
  float: left;
  font-size: 3.2em;
  line-height: 0.8;
  padding: 0.06em 0.1em 0 0;
  color: var(--color-ink);
}

.scroll-hint{
  margin-top: 2.5em;
  font-size: 1.6em;
  animation: bob 1.6s ease-in-out infinite;
}

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

/* Work slides */
.slide h2{
  letter-spacing: 0.04em;
  font-size: clamp(1.6em, 3vw, 2.2em);
  margin: 0 0 0.6em;
}

.intro{
  font-size: clamp(1.05em, 2.5vw, 1.5em);
  line-height: 1.65;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
  color: var(--color-ink-dim);
}

/* Card rows: wrapping flex keeps every row (incl. partial last rows) centered */
.container{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.25em;
  width: min(90%, 70em);
  margin: 0 auto;
}

.img_box{
  flex: 1 0 15em;    /* grow to fill complete rows, never shrink before wrapping */
  max-width: 17.5em; /* cap growth so partial rows stay compact and centered */
  display: block;
  background: linear-gradient(160deg, var(--color-bg-raised), var(--color-bg));
  border: 2px solid var(--color-ink);
  border-radius: var(--radius-card);
  position: relative;
  text-align: center;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.img_box:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-card-hover);
}

.img_box:focus-visible {
  outline: 3px solid var(--color-ink);
  outline-offset: 3px;
}

.mask{
  opacity: 0;
  background-color: rgba(0, 42, 19, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-radius: inherit;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 1em;
  box-sizing: border-box;
  transition: opacity 0.3s ease;
}
.img_box:hover .mask{
  opacity: 1;
}

.mask h2{
  font-size: 1.15em;
  line-height: 1.35;
  margin: 0;
}

/* Touch devices: no hover, show titles directly and let the whole card be tappable */
@media (hover: none) {
  .mask {
    opacity: 1;
  }
}

/* Entrance: cards fade in when their slide becomes active (main.js adds
   .slide-active via IntersectionObserver), instead of once on page load.
   html.js keeps cards visible if JS never runs. */
@media (prefers-reduced-motion: no-preference) {
  html.js .container > .img_box { opacity: 0; }
  html.js .slide-active .container > .img_box {
    opacity: 1;
    animation: cardIn 0.5s ease backwards;
  }
  html.js .slide-active .container > .img_box:nth-child(2) { animation-delay: 0.06s; }
  html.js .slide-active .container > .img_box:nth-child(3) { animation-delay: 0.12s; }
  html.js .slide-active .container > .img_box:nth-child(4) { animation-delay: 0.18s; }
  html.js .slide-active .container > .img_box:nth-child(5) { animation-delay: 0.24s; }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

/* Respect users who opt out of motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .content-section.active,
  html {
    scroll-behavior: auto !important;
  }
}

/* Film grain overlay: full-viewport canvas painted by js/main.js.
   Sits above everything (pointer-events: none) like a layer of film stock. */
#film-grain{
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2000;
  opacity: 0.2;
}

/* CRT vignette: screen corners and edges darken like an old tube monitor.
   Sits under the grain layer, above all page content; pure CSS, no animation. */
body::after{
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1900;
  background: radial-gradient(
    ellipse at center,
    transparent 55%,
    rgba(0, 0, 0, 0.32) 100%
  );
}

/* Small screens: tighter chrome */
@media (max-width: 640px) {
  .language-icon {
    margin: 0 10px;
  }
  #slide-nav {
    right: 8px;
  }
  .slide {
    padding: 80px 5vw 40px;
  }
  .container {
    gap: 0.9em;
  }
  .img_box {
    flex-basis: 11em;
    max-width: none;
  }
}
