/*
 * Personal Website — Pinguo Apple Design System
 * Brand anchor: Pinguo Blue #007AFF
 * Type: DM Sans + JetBrains Mono
 * Philosophy: Content first, whitespace is design, restraint is style.
 */

/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root {
  /* ── Color: Brand ── */
  --brand-50: #e8f2ff;
  --brand-100: #cfe5ff;
  --brand-200: #9fcbff;
  --brand-300: #66abff;
  --brand-400: #2e8dff;
  --brand-500: #007aff;
  --brand-600: #0064d6;
  --brand-700: #004fad;
  --brand-800: #003b82;
  --brand-900: #00275a;

  /* ── Color: Neutral / Background ── */
  --neutral-50: #ffffff;
  --neutral-100: #f7f7fa;
  --neutral-200: #f2f2f7;
  --neutral-300: #e5e5ea;
  --neutral-400: #d1d1d6;
  --neutral-500: #aeaeb2;
  --neutral-600: #8e8e93;
  --neutral-700: #3a3a3c;
  --neutral-800: #1c1c1e;
  --neutral-900: #000000;

  /* ── Color: Text ── */
  --text-50: #f5f5f7;
  --text-100: #e3e3e8;
  --text-200: #c7c7cc;
  --text-300: #aeaeb2;
  --text-400: #8e8e93;
  --text-500: #6e6e73;
  --text-600: #48484a;
  --text-700: #3c3c43;
  --text-800: #1d1d1f;
  --text-900: #000000;

  /* ── Color: State ── */
  --success: #34c759;
  --success-dark: #30d158;
  --success-surface: #e9f9ee;
  --error: #ff3b30;
  --error-dark: #ff453a;
  --error-surface: #ffecea;

  /* ── Semantic Roles (Light) ── */
  --bg: var(--neutral-50);
  --bg-alt: var(--neutral-200);
  --bg-card: var(--neutral-50);
  --fg: var(--text-800);
  --fg-muted: var(--text-400);
  --fg-subtle: var(--text-500);
  --primary: var(--brand-500);
  --primary-hover: var(--brand-600);
  --primary-fg: #ffffff;
  --secondary: var(--neutral-200);
  --secondary-fg: var(--text-800);
  --accent: var(--neutral-100);
  --accent-fg: var(--text-800);
  --border: var(--neutral-300);
  --input-border: var(--neutral-400);
  --ring: var(--brand-500);
  --nav-bg: var(--neutral-900);
  --nav-fg: var(--text-50);
  --nav-link-hover: var(--neutral-700);
  --destructive: var(--error);
  --destructive-fg: #ffffff;

  /* ── Typography ── */
  --font-sans: 'DM Sans', ui-sans-serif, sans-serif, system-ui;
  --font-mono: 'JetBrains Mono', monospace;
  --tracking-normal: 0em;

  /* ── Radius ── */
  --radius: 1.2rem;
  --radius-sm: 0.6rem;
  --radius-full: 999px;

  /* ── Shadows ── */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05), 0 1px 3px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 24px -8px rgba(0, 0, 0, 0.08), 0 4px 8px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 16px 40px -10px rgba(0, 0, 0, 0.10), 0 8px 16px -8px rgba(0, 0, 0, 0.06);
  --shadow-2xl: 0 24px 64px -12px rgba(0, 0, 0, 0.12);

  /* ── Spacing (base: 0.24rem ≈ 3.84px) ── */
  --space-1: 0.24rem;
  --space-2: 0.48rem;
  --space-3: 0.72rem;
  --space-4: 0.96rem;
  --space-6: 1.44rem;
  --space-8: 1.92rem;
  --space-12: 2.88rem;
  --space-16: 3.84rem;
  --space-24: 5.76rem;
  --space-32: 7.68rem;
  --space-48: 11.52rem;
  --space-64: 15.36rem;

  /* ── Motion ── */
  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 350ms;
}

/* ── Dark Mode ── */
.dark {
  --bg: var(--neutral-900);
  --bg-alt: var(--neutral-800);
  --bg-card: var(--neutral-800);
  --fg: var(--text-50);
  --fg-muted: var(--text-400);
  --fg-subtle: var(--text-500);
  --primary: var(--brand-400);
  --primary-hover: var(--brand-300);
  --primary-fg: var(--neutral-900);
  --secondary: var(--neutral-800);
  --secondary-fg: var(--text-50);
  --accent: var(--neutral-700);
  --accent-fg: var(--text-50);
  --border: var(--neutral-700);
  --input-border: var(--neutral-700);
  --nav-bg: var(--neutral-800);
  --nav-fg: var(--text-50);
  --nav-link-hover: var(--neutral-700);
  --destructive: var(--error-dark);

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.30);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.36), 0 1px 3px -1px rgba(0, 0, 0, 0.36);
  --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.44), 0 2px 4px -2px rgba(0, 0, 0, 0.36);
  --shadow-lg: 0 8px 24px -8px rgba(0, 0, 0, 0.50), 0 4px 8px -4px rgba(0, 0, 0, 0.40);
  --shadow-xl: 0 16px 40px -10px rgba(0, 0, 0, 0.55), 0 8px 16px -8px rgba(0, 0, 0, 0.44);
  --shadow-2xl: 0 24px 64px -12px rgba(0, 0, 0, 0.60);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

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

body {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: var(--tracking-normal);
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  transition: background-color var(--duration-normal) var(--ease-out),
              color var(--duration-normal) var(--ease-out);
}

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

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

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

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.5rem, 5vw, 5rem);
  letter-spacing: -0.04em;
  line-height: 0.92;
}

h2 {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  letter-spacing: -0.03em;
}

h3 {
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.eyebrow {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-3);
}

.body-lg {
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--fg-subtle);
}

.body-sm {
  font-size: 0.8125rem;
  color: var(--fg-muted);
}

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: var(--secondary);
  padding: 0.125em 0.375em;
  border-radius: var(--radius-sm);
}

/* ============================================================
   NAVIGATION — Apple Store-style dark bar
   ============================================================ */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 var(--space-8);
  background: var(--nav-bg);
  color: var(--nav-fg);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.site-nav .nav-inner {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  max-width: 1024px;
  width: 100%;
}

.site-nav .brand {
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--nav-fg);
  margin-right: auto;
}

.site-nav a {
  color: var(--text-200);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  transition: color var(--duration-fast) var(--ease-out);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
}

.site-nav a:hover {
  color: var(--nav-fg);
}

.site-nav .nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-left: auto;
}

.site-nav .theme-toggle {
  background: none;
  border: none;
  color: var(--text-200);
  cursor: pointer;
  font-size: 0.875rem;
  padding: var(--space-1);
  border-radius: var(--radius-full);
  transition: color var(--duration-fast) var(--ease-out);
}

.site-nav .theme-toggle:hover {
  color: var(--nav-fg);
}

/* ── Mobile Navigation ── */
@media (max-width: 640px) {
  .site-nav .nav-inner {
    gap: var(--space-4);
  }
  .site-nav a {
    font-size: 0.6875rem;
  }
}

/* ============================================================
   LAYOUT
   ============================================================ */

.container {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 var(--space-8);
}

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

.section-alt {
  background: var(--bg-alt);
}

@media (max-width: 640px) {
  .container {
    padding: 0 var(--space-6);
  }
  .section {
    padding: var(--space-16) 0;
  }
}

/* ============================================================
   BUTTONS — Pill-shaped Apple-style
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: var(--tracking-normal);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out),
              filter var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
  text-decoration: none;
  line-height: 1;
}

.btn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

/* Primary */
.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(0.92);
}

.btn-primary:active:not(:disabled) {
  filter: brightness(0.88);
}

/* Secondary */
.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-fg);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent);
}

/* Text */
.btn-text {
  height: 44px;
  padding: 0 4px;
  background: transparent;
  color: var(--primary);
  box-shadow: none;
  font-weight: 500;
}

.btn-text:hover:not(:disabled) {
  color: var(--primary-hover);
}

/* Large */
.btn-lg {
  height: 56px;
  padding: 0 28px;
  font-size: 1rem;
}

/* Small */
.btn-sm {
  height: 36px;
  padding: 0 16px;
  font-size: 0.75rem;
}

/* Danger */
.btn-danger {
  background: var(--destructive);
  color: var(--destructive-fg);
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(0.9);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  box-shadow: none;
  color: var(--fg-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--secondary);
  color: var(--fg);
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: var(--space-8);
  transition: transform var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out),
              border-color var(--duration-normal) var(--ease-out);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.card-header {
  margin-bottom: var(--space-6);
}

.card-body {
  color: var(--fg-subtle);
  font-size: 0.875rem;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.form-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.form-input,
.form-textarea {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  box-shadow: var(--shadow-xs);
}

.form-textarea {
  height: auto;
  min-height: 120px;
  padding: var(--space-4);
  line-height: 1.55;
  resize: vertical;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--fg-muted);
}

.form-input:disabled,
.form-textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.form-error {
  font-size: 0.75rem;
  color: var(--error);
  display: none;
}

.form-group.has-error .form-input,
.form-group.has-error .form-textarea {
  border-color: var(--error);
}

.form-group.has-error .form-error {
  display: block;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--fg-muted);
}

/* ============================================================
   HERO SECTION
   ============================================================ */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 70vh;
  padding: var(--space-32) var(--space-8);
}

.hero h1 {
  max-width: 720px;
  margin-bottom: var(--space-6);
}

.hero .hero-subtitle {
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--fg-subtle);
  max-width: 560px;
  margin-bottom: var(--space-12);
}

.hero .hero-actions {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 640px) {
  .hero {
    min-height: 60vh;
    padding: var(--space-16) var(--space-6);
  }
}

/* ============================================================
   GUESTBOOK
   ============================================================ */

.guestbook-form {
  max-width: 640px;
  margin: 0 auto var(--space-16);
}

.guestbook-list {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.message-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--duration-fast) var(--ease-out);
}

.message-card:hover {
  border-color: var(--border);
}

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.message-author {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--fg);
}

.message-time {
  font-size: 0.75rem;
  color: var(--fg-muted);
  font-family: var(--font-mono);
}

.message-body {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--fg);
  word-break: break-word;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-3);
}

.guestbook-empty {
  text-align: center;
  padding: var(--space-16) 0;
  color: var(--fg-muted);
}

.guestbook-loading {
  text-align: center;
  padding: var(--space-8);
  color: var(--fg-muted);
  font-size: 0.875rem;
}

.guestbook-error {
  text-align: center;
  padding: var(--space-8);
  color: var(--error);
  font-size: 0.875rem;
}

/* ============================================================
   AUTH PAGES
   ============================================================ */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 44px);
  padding: var(--space-8);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-12);
  box-shadow: var(--shadow-md);
}

.auth-card h2 {
  text-align: center;
  margin-bottom: var(--space-2);
}

.auth-card .auth-subtitle {
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.875rem;
  margin-bottom: var(--space-8);
}

.auth-toggle {
  text-align: center;
  margin-top: var(--space-6);
  font-size: 0.875rem;
  color: var(--fg-muted);
}

.auth-toggle a {
  font-weight: 600;
  cursor: pointer;
}

.auth-message {
  text-align: center;
  font-size: 0.8125rem;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-6);
  display: none;
}

.auth-message.show {
  display: block;
}

.auth-message.success {
  background: var(--success-surface);
  color: var(--success);
}

.auth-message.error {
  background: var(--error-surface);
  color: var(--error);
}

/* ============================================================
   USER MENU (in nav)
   ============================================================ */

.user-menu {
  display: none;
  align-items: center;
  gap: var(--space-4);
}

.user-menu.logged-in {
  display: flex;
}

.user-menu .username {
  font-size: 0.75rem;
  color: var(--nav-fg);
  font-weight: 500;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

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

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--fg-muted);
}

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.hidden {
  display: none !important;
}

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

.site-footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: var(--space-8) 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.site-footer .footer-inner {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 var(--space-8);
}

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

@media (max-width: 640px) {
  .auth-card {
    padding: var(--space-8);
  }
  .card {
    padding: var(--space-6);
  }
}

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

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

.animate-in {
  animation: fadeIn var(--duration-slow) var(--ease-out) both;
}
