/* ============================================================
   printacalendar — Design System
   Aesthetic: warm editorial. Cream paper, ink text, terracotta.
   All theme decisions live in the :root tokens below.
   ============================================================ */

/* ---------- Fonts (self-hosted) ---------- */
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  /* Neutral ramp (warm) */
  --paper:        #faf6ee;
  --paper-raised: #fffdf8;
  --paper-sunken: #f3edde;
  --ink:          #221e19;
  --ink-soft:     #5f564b;
  --ink-faint:    #988d7d;
  --line:         #e6ddca;
  --line-soft:    #f0e9da;

  /* Primary + accent */
  --accent:       #c05b33;   /* terracotta */
  --accent-deep:  #9a411d;
  --accent-wash:  #f7e7dc;

  /* Semantic */
  --c-today:      var(--accent);
  --c-holiday:    #31695e;   /* deep teal */
  --c-holiday-wash: #e6efeb;
  --c-note:       #8a6d1f;
  --c-note-wash:  #f6efd8;
  --c-weekend:    #f5efe1;

  /* Typography */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --text-xs:  0.72rem;
  --text-sm:  0.84rem;
  --text-md:  0.95rem;
  --text-lg:  1.15rem;
  --text-xl:  1.5rem;
  --text-display: clamp(2.1rem, 5.5vw, 3.4rem);

  /* Spacing scale */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2.25rem;
  --sp-7: 3.5rem;

  /* Radius scale */
  --r-1: 6px;
  --r-2: 10px;
  --r-3: 16px;
  --r-pill: 999px;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(60, 45, 30, 0.06);
  --shadow-2: 0 2px 10px rgba(60, 45, 30, 0.08), 0 1px 3px rgba(60, 45, 30, 0.05);

  /* Motion */
  --ease: cubic-bezier(0.25, 0.6, 0.3, 1);
  --t-fast: 150ms;
  --t-med: 220ms;
}

/* ---------- Dark mode (warm ink) ---------- */
:root[data-theme="dark"] {
  --paper:        #211c16;
  --paper-raised: #2a241d;
  --paper-sunken: #191510;
  --ink:          #f2ead9;
  --ink-soft:     #c7bba6;
  --ink-faint:    #8f8474;
  --line:         #3d362b;
  --line-soft:    #332d23;

  --accent:       #d97a4e;
  --accent-deep:  #e69678;   /* hover brightens on dark */
  --accent-wash:  #43291c;

  --c-holiday:    #7cc0ad;
  --c-holiday-wash: #1f332d;
  --c-note:       #d8bc6a;
  --c-note-wash:  #34301f;
  --c-weekend:    #272118;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 2px 10px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] select.field {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23c7bba6' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body { overflow-x: hidden; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
}

a {
  color: var(--accent-deep);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--accent); }

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

::selection { background: var(--accent-wash); }

.container {
  width: min(1120px, 100% - 2 * var(--sp-4));
  margin-inline: auto;
}

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

.js-hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 0.55em 1.2em;
  cursor: pointer;
  transition:
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}
.btn:hover {
  border-color: var(--ink-faint);
  box-shadow: var(--shadow-1);
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.btn-primary:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  box-shadow: var(--shadow-2);
}

.btn-icon {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: var(--r-pill);
}
.btn-icon svg { display: block; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--paper-sunken);
  border-color: transparent;
  box-shadow: none;
}

/* ---------- Segmented control (week start) ---------- */
.seg {
  display: inline-flex;
  background: var(--paper-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 2px;
}
.seg a {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0.35em 0.9em;
  border-radius: var(--r-pill);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg a:hover { color: var(--ink); }
.seg a[aria-current="true"] {
  background: var(--paper-raised);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

/* ---------- Form controls ---------- */
select.field {
  appearance: none;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
  background-color: var(--paper-raised);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235f564b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8em center;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 0.5em 2.2em 0.5em 1em;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease);
}
select.field:hover { border-color: var(--ink-faint); }

/* ---------- Site header / footer ---------- */
.site-header {
  border-bottom: 1px solid var(--line-soft);
  background: var(--paper);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--sp-4);
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.7rem;
  letter-spacing: -0.015em;
  line-height: 1;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 0.42em;
}
.wordmark:hover { color: var(--ink); }

.logo-mark {
  flex: none;
  transition: transform var(--t-med) var(--ease);
}
.wordmark:hover .logo-mark {
  transform: rotate(-6deg) scale(1.05);
}

.wordmark em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
  padding-inline: 0.045em;
  transition: color var(--t-fast) var(--ease);
}
.wordmark:hover em { color: var(--accent-deep); }

/* ---------- Mobile header / nav ---------- */

/* Show/hide helpers */
.mobile-only { display: none !important; }
.desktop-only { display: inline-flex !important; }

/* Mobile theme icon: show correct icon based on theme */
.theme-icon-btn .icon-sun  { display: block; }
.theme-icon-btn .icon-moon { display: none; }
[data-theme="dark"] .theme-icon-btn .icon-sun  { display: none; }
[data-theme="dark"] .theme-icon-btn .icon-moon { display: block; }

/* Hamburger: ham-close hidden by default, shown when open */
.nav-hamburger .ham-close { display: none; }
.nav-hamburger[aria-expanded="true"] .ham-open  { display: none; }
.nav-hamburger[aria-expanded="true"] .ham-close { display: block; }

/* Mobile nav dropdown */
.mobile-nav {
  display: none;
  border-top: 1px solid var(--line-soft);
  background: var(--paper);
}
.mobile-nav.is-open {
  display: block;
}
.mobile-nav .container {
  display: flex;
  flex-direction: column;
  padding-block: var(--sp-3);
  gap: 0;
}
.mobile-nav a {
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--ink-soft);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--line-soft);
  transition: color var(--t-fast) var(--ease);
}
.mobile-nav a:last-child { border-bottom: none; }
.mobile-nav a:hover,
.mobile-nav a[aria-current="page"] { color: var(--ink); }
.mobile-nav a[aria-current="page"] { font-weight: 600; color: var(--accent); }

@media (max-width: 768px) {
  /* Logo: bigger on mobile */
  .wordmark { font-size: 1.55rem; }
  .logo-mark { width: 36px; height: 36px; }

  /* Show mobile controls, hide desktop ones */
  .mobile-only  { display: inline-flex !important; }
  .desktop-only { display: none !important; }

  /* Hide desktop nav */
  .site-nav { display: none !important; }

  /* Tighter header on mobile */
  .site-header .container { padding-block: var(--sp-3); }
  .header-tools { gap: var(--sp-2); }

  /* Icon buttons slightly smaller */
  .theme-icon-btn,
  .nav-hamburger { width: 2.2rem; height: 2.2rem; }
}

.header-tools {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

/* Segmented buttons (theme toggle etc.) — mirrors .seg a styling */
.seg button {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: none;
  border: none;
  border-radius: var(--r-pill);
  padding: 0.35em 0.9em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] {
  background: var(--paper-raised);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.theme-seg button { padding: 0.4em 0.75em; }
.theme-seg svg { display: block; }

.site-nav {
  display: flex;
  gap: var(--sp-5);
  font-size: var(--text-sm);
  font-weight: 500;
}
.site-nav a { color: var(--ink-soft); }
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
}

.site-footer {
  border-top: 1px solid var(--line-soft);
  margin-top: var(--sp-7);
}
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3) var(--sp-5);
  align-items: center;
  justify-content: space-between;
  padding-block: var(--sp-5);
  font-size: var(--text-xs);
  color: var(--ink-faint);
}
.site-footer a { color: var(--ink-soft); }
.footer-links {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-2);
}
.footer-sep { color: var(--line); }

@media (max-width: 768px) {
  .site-footer .container {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-3);
    padding-block: var(--sp-4);
  }
  .footer-links {
    gap: var(--sp-1) var(--sp-2);
    row-gap: var(--sp-2);
  }
}

/* ---------- Prose pages (privacy policy etc.) ---------- */
.prose {
  max-width: 68ch;
  padding-block: var(--sp-6);
}
.prose h1 { font-size: var(--text-display); margin-bottom: var(--sp-2); }
.prose h2 { font-size: var(--text-xl); margin: var(--sp-5) 0 var(--sp-2); }
.prose p { color: var(--ink-soft); margin: 0 0 var(--sp-3); }
.prose-updated { font-size: var(--text-xs); color: var(--ink-faint); }

/* ---------- Share dialog ---------- */
.share-dialog {
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--paper-raised);
  box-shadow: 0 18px 50px rgba(40, 30, 20, 0.22);
  padding: var(--sp-5);
  width: min(420px, calc(100vw - 2 * var(--sp-4)));
  color: var(--ink);
}
.share-dialog::backdrop {
  background: rgba(34, 30, 25, 0.45);
}
.share-dialog[open] {
  animation: share-pop var(--t-med) var(--ease) both;
}
@keyframes share-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.share-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.share-head h2 {
  font-size: var(--text-xl);
  font-weight: 600;
}

.share-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  margin-block: var(--sp-4);
}
.share-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink);
  transition: border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.share-opt:hover {
  border-color: var(--ink-faint);
  background: var(--paper-sunken);
  color: var(--ink);
  transform: translateY(-1px);
}

.share-ic {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.share-ic-fb { background: #1877f2; }
.share-ic-x { background: #14171a; }
.share-ic-gm { background: #ea4335; }

.share-copy {
  display: flex;
  gap: var(--sp-2);
}
.share-copy .field-text {
  flex: 1;
  min-width: 0;
  font-size: var(--text-xs);
  color: var(--ink-soft);
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
