/* ===================================
   Portfolio Case Study — tonyalicea.dev
   =================================== */

/* --- Custom Properties --- */
:root {
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Literata', Georgia, serif;
  --font-ui: 'Manrope', system-ui, sans-serif;

  /* Light theme */
  --bg: #FAF9F6;
  --bg-subtle: #F2F1EC;
  --text: #1D1D1F;
  --text-2: #636366;
  --text-3: #98989D;
  --accent: #4A6B52;
  --accent-hover: #3A5641;
  --accent-light: #EAF0EB;
  --border: #E5E4DF;
  --border-light: #EDECE7;
  --placeholder-bg: #EAEAE5;
  --placeholder-fg: #CDCDC7;
  --selection-bg: #4A6B52;
  --selection-text: #fff;
}

/* Dark theme — JS-driven */
html[data-theme="dark"] {
  --bg: #161618;
  --bg-subtle: #1E1E21;
  --text: #E5E5E7;
  --text-2: #98989D;
  --text-3: #636366;
  --accent: #7FB589;
  --accent-hover: #99CBAA;
  --accent-light: #1E2B21;
  --border: #2C2C2E;
  --border-light: #232325;
  --placeholder-bg: #232325;
  --placeholder-fg: #3A3A3C;
  --selection-bg: #7FB589;
  --selection-text: #161618;
}

/* Dark theme — no-JS fallback */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #161618;
    --bg-subtle: #1E1E21;
    --text: #E5E5E7;
    --text-2: #98989D;
    --text-3: #636366;
    --accent: #7FB589;
    --accent-hover: #99CBAA;
    --accent-light: #1E2B21;
    --border: #2C2C2E;
    --border-light: #232325;
    --placeholder-bg: #232325;
    --placeholder-fg: #3A3A3C;
    --selection-bg: #7FB589;
    --selection-text: #161618;
  }
}

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

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

body {
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.72;
  color: var(--text);
  background: var(--bg);
  font-optical-sizing: auto;
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

/* --- Page Load Animation --- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Case Study --- */
.case-study {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Nav --- */
.case-study__nav {
  padding: 1.5rem 2rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: fadeUp 0.6s ease both;
}

.nav__home {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s;
}

.nav__home:hover {
  color: var(--accent);
}

.nav__sep {
  color: var(--text-3);
  font-size: 0.65rem;
}

.nav__label {
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.2s;
}

.nav__label:hover {
  color: var(--accent);
}

/* --- Theme Toggle --- */
.theme-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem;
  cursor: pointer;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-3);
  background: var(--bg-subtle);
}

/* Default: show moon (switch to dark) */
.theme-toggle__sun {
  display: none;
}

/* Dark mode: show sun (switch to light) */
html[data-theme="dark"] .theme-toggle__sun {
  display: block;
}

html[data-theme="dark"] .theme-toggle__moon {
  display: none;
}

/* Hide toggle entirely if JS hasn't run */
html:not([data-theme]) .theme-toggle {
  display: none;
}

/* --- Hero --- */
.case-study__hero {
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-subtle);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.hero__inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 2rem 3.5rem;
  animation: fadeUp 0.6s ease 0.1s both;
}

.hero__category {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.8rem;
  line-height: 1.12;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 0.6rem;
}

.hero__subtitle {
  font-size: 1.12rem;
  font-weight: 300;
  font-style: italic;
  line-height: 1.55;
  color: var(--text-2);
  max-width: 56ch;
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.meta__item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.meta__label {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.meta__value {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text);
}

/* --- Body Content --- */
.case-study__body {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 3rem 2rem 5rem;
  flex: 1;
  animation: fadeUp 0.6s ease 0.2s both;
}

/* Headings */
.case-study__body h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.55rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-top: 3rem;
  margin-bottom: 1rem;
}

.case-study__body h2:first-child {
  margin-top: 0;
}

.case-study__body h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.18rem;
  line-height: 1.35;
  color: var(--text);
  margin-top: 2.25rem;
  margin-bottom: 0.65rem;
}

/* Paragraphs */
.case-study__body p {
  margin-bottom: 1.2rem;
  max-width: 65ch;
}

/* Links */
.case-study__body a {
  color: var(--accent);
  text-decoration-line: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  transition: text-decoration-color 0.2s, color 0.2s;
}

.case-study__body a:hover {
  color: var(--accent-hover);
  text-decoration-color: var(--accent-hover);
}

/* Bold & Italic */
.case-study__body strong {
  font-weight: 600;
}

.case-study__body em {
  font-style: italic;
}

/* Lists */
.case-study__body ul,
.case-study__body ol {
  margin-bottom: 1.2rem;
  padding-left: 1.4rem;
  max-width: 65ch;
}

.case-study__body li {
  margin-bottom: 0.35rem;
  padding-left: 0.2rem;
}

.case-study__body li::marker {
  color: var(--accent);
}

/* Blockquote — callout style */
.case-study__body blockquote {
  margin: 2.25rem 0;
  padding: 1.2rem 1.5rem;
  background: var(--bg-subtle);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
}

.case-study__body blockquote p {
  font-style: italic;
  color: var(--text-2);
  margin-bottom: 0;
  max-width: none;
}

/* Horizontal rule — section divider */
.case-study__body hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 3.5rem 0;
}

/* Images */
.case-study__body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 2rem 0;
  border: 1px solid var(--border-light);
}

/* Image placeholders */
.image-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--placeholder-bg);
  border: 1px dashed var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2rem 0;
}

.image-placeholder::after {
  content: 'Image';
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--placeholder-fg);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.image-placeholder--wide {
  aspect-ratio: 2.35 / 1;
}

.image-placeholder--square {
  aspect-ratio: 1;
  max-width: 400px;
}

/* --- Theme-Aware Images --- */
.theme-img {
  margin: 2rem 0;
}

.theme-img img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 0;
  border: 1px solid var(--border-light);
}

.theme-img--sm {
  text-align: center;
}

.theme-img--sm img {
  max-width: 300px;
}

/* Default: show light, hide dark */
.theme-img--dark {
  display: none;
}

/* JS-driven dark mode */
html[data-theme="dark"] .theme-img--light {
  display: none;
}

html[data-theme="dark"] .theme-img--dark {
  display: inline;
}

/* No-JS fallback */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .theme-img--light {
    display: none;
  }

  html:not([data-theme="light"]) .theme-img--dark {
    display: inline;
  }
}

/* --- Portfolio Index --- */
.portfolio {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.portfolio__header {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 4rem 2rem 0;
  animation: fadeUp 0.6s ease 0.1s both;
}

.portfolio__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.8rem;
  line-height: 1.12;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.portfolio__intro {
  font-size: 1.1rem;
  color: var(--text-2);
  font-style: italic;
  line-height: 1.55;
  max-width: 50ch;
}

.portfolio__entries {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 2rem 0;
  flex: 1;
  animation: fadeUp 0.6s ease 0.2s both;
}

.portfolio__card {
  display: block;
  text-decoration: none;
  color: var(--text);
  padding: 1.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.portfolio__card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 12%, transparent);
  transform: translateY(-2px);
}

.card__category {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.card__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}

.card__excerpt {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 1rem;
  max-width: 55ch;
}

.card__cta {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  transition: color 0.2s;
}

.portfolio__card:hover .card__cta {
  color: var(--accent-hover);
}

.portfolio__note {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text-3);
  text-align: center;
  animation: fadeUp 0.6s ease 0.3s both;
}

/* --- Footer --- */
.case-study__footer {
  border-top: 1px solid var(--border-light);
  padding: 2rem;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-3);
  animation: fadeUp 0.6s ease 0.3s both;
}

.case-study__footer a {
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.2s;
}

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

/* --- Responsive --- */
@media (max-width: 768px) {
  html {
    font-size: 19px;
  }

  .case-study__nav {
    padding: 1.25rem 1.5rem;
  }

  .hero__inner {
    padding: 2.25rem 1.5rem 2.75rem;
  }

  .hero__title {
    font-size: 2.1rem;
  }

  .hero__meta {
    gap: 1.5rem;
  }

  .case-study__body {
    padding: 2.25rem 1.5rem 3.5rem;
  }

  .portfolio__header {
    padding: 3rem 1.5rem 0;
  }

  .portfolio__title {
    font-size: 2.1rem;
  }

  .portfolio__entries {
    padding: 2rem 1.5rem 0;
  }

  .portfolio__note {
    padding: 2.5rem 1.5rem 3rem;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 18px;
  }

  .hero__inner {
    padding: 1.75rem 1.25rem 2.25rem;
  }

  .hero__title {
    font-size: 1.8rem;
  }

  .hero__subtitle {
    font-size: 1rem;
  }

  .hero__meta {
    flex-direction: column;
    gap: 1rem;
  }

  .case-study__body {
    padding: 1.75rem 1.25rem 3rem;
  }

  .case-study__nav {
    padding: 1rem 1.25rem;
  }

  .portfolio__header {
    padding: 2.5rem 1.25rem 0;
  }

  .portfolio__title {
    font-size: 1.8rem;
  }

  .portfolio__entries {
    padding: 1.75rem 1.25rem 0;
  }

  .portfolio__card {
    padding: 1.25rem;
  }

  .portfolio__note {
    padding: 2rem 1.25rem 2.5rem;
  }
}

/* --- Print --- */
@media print {
  :root {
    --bg: #fff;
    --bg-subtle: #fff;
    --text: #000;
    --text-2: #333;
    --text-3: #666;
    --accent: #2d5a36;
    --border: #ccc;
    --border-light: #ddd;
  }

  html {
    font-size: 12pt;
  }

  body {
    background: #fff;
  }

  .case-study__nav,
  .case-study__footer {
    display: none;
  }

  .case-study__hero {
    border-bottom: 1px solid #ccc;
  }

  .image-placeholder {
    border-style: solid;
  }

  @page {
    margin: 1in;
  }
}
