/* ==========================================================================
   RE:PERSONAL — Base Styles
   "Editorial Intelligence" Design System
   Reset, typography, links, layout utilities, animations
   ========================================================================== */

/* ── Reset ──────────────────────────────────────────────────────────────── */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.75;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

ul,
ol {
  list-style: none;
}

a {
  text-decoration: none;
  color: inherit;
  transition: color var(--ease);
}

a:hover {
  color: var(--accent);
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

fieldset {
  border: none;
}

/* Remove default search input appearance */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* ── Typography ─────────────────────────────────────────────────────────── */

/* Serif headings for editorial weight — Korean editorial feel */
h1, h2 {
  font-family: var(--font-serif);
  font-weight: 900;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* Geometric sans for subheadings */
h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  font-weight: 700;
  line-height: 1.25;
}

h3 {
  font-size: clamp(1.1rem, 2vw, 1.4rem);
}

h4 {
  font-size: var(--text-lg);
  font-weight: 700;
}

h5 {
  font-size: var(--text-md);
  font-weight: 600;
}

h6 {
  font-size: 1rem;
  font-weight: 600;
}

p {
  margin-bottom: var(--space-md);
  line-height: 1.75;
  color: var(--text-secondary);
}

p:last-child {
  margin-bottom: 0;
}

strong, b {
  font-weight: 700;
}

em, i {
  font-style: italic;
}

small {
  font-size: 0.875rem;
}

/* ── Selection ──────────────────────────────────────────────────────────── */

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

/* ── Layout Utilities ───────────────────────────────────────────────────── */

.container {
  width: 100%;
  max-width: var(--container);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

.container--narrow,
.narrow {
  max-width: var(--narrow);
}

.section {
  padding: var(--space-4xl) 0;
}

.section--dark {
  background: var(--bg-dark);
  color: var(--text-inverse);
}

.section--dark h1,
.section--dark h2,
.section--dark h3,
.section--dark h4,
.section--dark h5,
.section--dark h6 {
  color: var(--text-inverse);
}

.section--dark p {
  color: var(--text-inverse-muted);
}

@media (max-width: 767px) {
  .section {
    padding: var(--space-3xl) 0;
  }
}

/* Section inner wrapper — used in HTML */
.section-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--pad);
}

/* Background utilities */
.bg-warm {
  background: var(--bg-warm);
}

.bg-surface {
  background: var(--surface);
}

/* Serif heading utility */
.serif-heading {
  font-family: var(--font-body);
  font-weight: 800;
}

/* Section number (large decorative) */
.section-number {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(3rem, 7vw, 5rem);
  color: rgba(0, 0, 0, 0.03);
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

/* Section subtext */
.section-subtext {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 300;
  line-height: 1.75;
  max-width: 560px;
  margin-bottom: var(--space-lg);
}

/* ── Visually Hidden (a11y) ─────────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Reveal Animations ──────────────────────────────────────────────────── */

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

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Base reveal — default: slide up */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Directional variants */
.reveal-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-left.is-visible {
  opacity: 1;
  transform: none;
}

.reveal-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-right.is-visible {
  opacity: 1;
  transform: none;
}

.reveal-scale {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-scale.is-visible {
  opacity: 1;
  transform: none;
}

/* Stagger children with CSS custom property --i */
.stagger > * {
  transition-delay: calc(var(--i, 0) * 80ms);
}

/* Legacy fade-in classes — backwards compatibility */
.fade-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-in.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children — legacy class used in HTML */
.fade-in-stagger > *,
.stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-in-stagger.is-visible > *:nth-child(1),
.stagger-children.is-visible > *:nth-child(1)  { transition-delay: 0s; }
.fade-in-stagger.is-visible > *:nth-child(2),
.stagger-children.is-visible > *:nth-child(2)  { transition-delay: 0.08s; }
.fade-in-stagger.is-visible > *:nth-child(3),
.stagger-children.is-visible > *:nth-child(3)  { transition-delay: 0.16s; }
.fade-in-stagger.is-visible > *:nth-child(4),
.stagger-children.is-visible > *:nth-child(4)  { transition-delay: 0.24s; }
.fade-in-stagger.is-visible > *:nth-child(5),
.stagger-children.is-visible > *:nth-child(5)  { transition-delay: 0.32s; }
.fade-in-stagger.is-visible > *:nth-child(6),
.stagger-children.is-visible > *:nth-child(6)  { transition-delay: 0.40s; }
.fade-in-stagger.is-visible > *:nth-child(7),
.stagger-children.is-visible > *:nth-child(7)  { transition-delay: 0.48s; }
.fade-in-stagger.is-visible > *:nth-child(8),
.stagger-children.is-visible > *:nth-child(8)  { transition-delay: 0.56s; }
.fade-in-stagger.is-visible > *:nth-child(9),
.stagger-children.is-visible > *:nth-child(9)  { transition-delay: 0.64s; }
.fade-in-stagger.is-visible > *:nth-child(10),
.stagger-children.is-visible > *:nth-child(10) { transition-delay: 0.72s; }
.fade-in-stagger.is-visible > *:nth-child(11),
.stagger-children.is-visible > *:nth-child(11) { transition-delay: 0.80s; }
.fade-in-stagger.is-visible > *:nth-child(12),
.stagger-children.is-visible > *:nth-child(12) { transition-delay: 0.88s; }

.fade-in-stagger.is-visible > *,
.stagger-children.is-visible > * {
  opacity: 1;
  transform: translateY(0);
}
