/* ==========================================================================
   Porchlink v1.0.0 - core.css
   Shared structure for every Porchlink link-in-bio page.
   Each theme file (assets/css/themes/<name>.css) only sets the variables
   below and adds its own decoration, so you can restyle a page by editing
   one small file.

   TABLE OF CONTENTS
   1. Theme variable contract
   2. Reset and base
   3. Accessibility helpers (skip link, focus, visually hidden)
   4. Top bar (share, QR, light/dark buttons)
   5. Profile (avatar, name, handle, bio, social icons)
   6. Featured card
   7. Link list and link groups
   8. Copy-a-code block
   9. Info block (schedule / tracklist / list)
   10. Newsletter form
   11. Footer
   12. Toast and QR dialog
   13. Page-load sequence
   14. Reduced motion
   ========================================================================== */

/* 1. Theme variable contract ------------------------------------------------
   Every theme defines these on [data-theme="name"] and again on
   [data-theme="name"][data-mode="dark"]. Defaults below keep a page usable
   even without a theme file. */
:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --ink: #1c2126;
  --muted: #5b6570;
  --accent: #2f5bd3;
  --accent-ink: #ffffff;
  --line: rgba(28, 33, 38, .16);
  --focus: #2f5bd3;
  --font-display: 'Instrument Sans', system-ui, sans-serif;
  --font-body: 'Instrument Sans', system-ui, sans-serif;
  --radius: 14px;          /* link buttons */
  --radius-card: 18px;     /* featured card, form */
  --link-pad: 15px 18px;
  --page-width: 34rem;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
[data-mode="dark"] { color-scheme: dark; }

/* 2. Reset and base -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color .35s var(--ease), color .35s var(--ease);
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

/* Decorative background layer each theme may fill */
.pl-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.pl-bg svg { width: 100%; height: 100%; }

.pl-page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 8px 16px 40px;
  display: grid;
  gap: 22px;
}

/* 3. Accessibility helpers ------------------------------------------------- */
.pl-skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--ink); color: var(--bg);
  padding: 10px 14px; border-radius: 8px; text-decoration: none; font-weight: 600;
}
.pl-skip:focus { top: 12px; }
.pl-sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* 4. Top bar --------------------------------------------------------------- */
.pl-top {
  position: relative; z-index: 2;
  max-width: var(--page-width); margin: 0 auto;
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 16px 0;
}
.pl-btn-icon {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); cursor: pointer;
  transition: transform .2s var(--ease), background-color .2s;
}
.pl-btn-icon:hover { transform: translateY(-1px); }
.pl-btn-icon svg { width: 19px; height: 19px; }
.pl-btn-icon .i-moon { display: none; }
[data-mode="dark"] .pl-btn-icon .i-sun { display: none; }
[data-mode="dark"] .pl-btn-icon .i-moon { display: block; }

/* 5. Profile --------------------------------------------------------------- */
.pl-profile { display: grid; justify-items: center; text-align: center; gap: 10px; padding-top: 6px; }
.pl-avatar {
  width: 112px; height: 112px; border-radius: 50%; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
}
.pl-avatar svg, .pl-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pl-name {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 7vw, 2.2rem); line-height: 1.1; font-weight: 600;
  overflow-wrap: anywhere;
}
.pl-handle { color: var(--muted); font-size: .95rem; }
.pl-bio { max-width: 30ch; font-size: 1.02rem; }
.pl-social { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 4px; }
.pl-social a {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink);
  border: 1px solid var(--line); background: var(--surface);
  transition: transform .2s var(--ease), background-color .2s, color .2s;
}
.pl-social a:hover { background: var(--accent); color: var(--accent-ink); transform: translateY(-2px); }
.pl-social svg { width: 18px; height: 18px; }

/* 6. Featured card --------------------------------------------------------- */
.pl-feature {
  display: grid; grid-template-columns: 104px 1fr; gap: 14px; align-items: center;
  padding: 12px; border-radius: var(--radius-card);
  background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; color: inherit;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.pl-feature:hover { transform: translateY(-2px); }
.pl-feature-art { width: 104px; height: 104px; border-radius: calc(var(--radius-card) - 6px); overflow: hidden; }
.pl-feature-art svg { width: 100%; height: 100%; }
.pl-feature-kicker, .pl-feature-title, .pl-feature-text { display: block; }
.pl-feature-kicker { font-size: .82rem; color: var(--muted); }
.pl-feature-title { font-family: var(--font-display); font-size: 1.15rem; line-height: 1.2; margin: 2px 0 4px; }
.pl-feature-text { font-size: .9rem; color: var(--muted); }

/* 7. Link list and link groups -------------------------------------------- */
.pl-links { display: grid; gap: 12px; }
.pl-link {
  position: relative;
  display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 12px;
  min-height: 58px; padding: var(--link-pad);
  border-radius: var(--radius); background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); text-decoration: none;
  transition: transform .2s var(--ease), background-color .2s, color .2s, box-shadow .2s;
}
.pl-link:hover { transform: translateY(-2px); }
.pl-link:active { transform: translateY(0) scale(.99); }
.pl-link-icon { width: 24px; height: 24px; justify-self: center; }
.pl-link-icon svg { width: 100%; height: 100%; }
.pl-link-label { font-weight: 600; line-height: 1.25; }
.pl-link-sub { display: block; font-weight: 400; font-size: .86rem; color: var(--muted); }
.pl-link--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.pl-link--primary .pl-link-sub { color: inherit; opacity: .85; }

.pl-group { border-radius: var(--radius-card); border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.pl-group > summary {
  list-style: none; cursor: pointer; padding: 15px 18px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  font-weight: 600; border-radius: var(--radius-card);
}
.pl-group > summary::-webkit-details-marker { display: none; }
.pl-group > summary .pl-chev { width: 18px; height: 18px; transition: transform .25s var(--ease); flex: none; }
.pl-group[open] > summary .pl-chev { transform: rotate(180deg); }
.pl-group .pl-links { padding: 0 12px 12px; }
.pl-group-count { font-weight: 400; color: var(--muted); font-size: .9rem; }

/* 8. Copy-a-code block ----------------------------------------------------- */
.pl-code {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 14px 16px; border-radius: var(--radius-card);
  border: 2px dashed var(--line); background: transparent;
}
.pl-code-label { font-size: .9rem; color: var(--muted); }
.pl-code-value { font-family: var(--font-display); font-size: 1.3rem; letter-spacing: .04em; overflow-wrap: anywhere; }
.pl-code button {
  grid-row: 1 / span 2; grid-column: 2;
  padding: 10px 16px; border-radius: 999px; cursor: pointer;
  background: var(--ink); color: var(--bg); border: 0; font-weight: 600;
}

/* 9. Info block ------------------------------------------------------------ */
.pl-info { padding: 18px; border-radius: var(--radius-card); background: var(--surface); border: 1px solid var(--line); }
.pl-info h2 { font-family: var(--font-display); font-size: 1.1rem; margin-bottom: 10px; }
.pl-info-list li {
  display: flex; justify-content: space-between; gap: 12px; padding: 9px 0;
  border-top: 1px solid var(--line); font-size: .95rem;
}
.pl-info-list li:first-child { border-top: 0; }
.pl-info-list span:last-child { color: var(--muted); text-align: right; }

/* 10. Newsletter form ------------------------------------------------------ */
.pl-form { padding: 18px; border-radius: var(--radius-card); background: var(--surface); border: 1px solid var(--line); display: grid; gap: 10px; }
.pl-form h2 { font-family: var(--font-display); font-size: 1.15rem; }
.pl-form p { color: var(--muted); font-size: .92rem; }
.pl-form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pl-form input[type="email"] {
  flex: 1 1 180px; min-width: 0; height: 48px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.pl-form input[aria-invalid="true"] { border-color: #c0392b; box-shadow: 0 0 0 2px rgba(192, 57, 43, .25); }
.pl-form button {
  flex: 0 0 auto; height: 48px; padding: 0 18px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.pl-form button[disabled] { opacity: .6; cursor: progress; }
.pl-form-status { font-size: .9rem; min-height: 1.35em; }
.pl-form-status[data-state="error"] { color: #c0392b; }
[data-mode="dark"] .pl-form-status[data-state="error"] { color: #ff8b7e; }
[data-mode="dark"] .pl-form input[aria-invalid="true"] { border-color: #ff8b7e; }
.pl-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; } /* spam honeypot */

/* 11. Footer --------------------------------------------------------------- */
.pl-foot { text-align: center; font-size: .82rem; color: var(--muted); padding: 4px 0 8px; }
.pl-foot a { color: inherit; }

/* 12. Toast and QR dialog -------------------------------------------------- */
.pl-toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 11px 18px; border-radius: 999px; font-size: .92rem; font-weight: 600;
  background: var(--ink); color: var(--bg); max-width: calc(100vw - 32px);
  transition: transform .3s var(--ease), opacity .3s var(--ease);
}
.pl-toast.is-on { transform: translate(-50%, 0); opacity: 1; }

.pl-qr { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: calc(100vw - 32px); }
.pl-qr::backdrop { background: rgba(10, 12, 16, .55); }
.pl-qr-card {
  width: min(340px, calc(100vw - 32px)); padding: 22px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line); text-align: center; display: grid; gap: 12px;
}
.pl-qr-card h2 { font-family: var(--font-display); font-size: 1.2rem; }
.pl-qr-card p { font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; }
.pl-qr-canvas { width: 100%; max-width: 260px; aspect-ratio: 1; margin: 0 auto; background: #fff; border-radius: 12px; padding: 12px; }
.pl-qr-canvas svg { width: 100%; height: 100%; }
.pl-qr-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.pl-qr-actions button, .pl-qr-actions a {
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg);
  cursor: pointer; font-weight: 600; text-decoration: none; font-size: .92rem;
}

/* 13. Page-load sequence ----------------------------------------------------
   One orchestrated entrance: profile, then each block in order. The --i
   index is set by core.js; without JS nothing is hidden. */
.pl-ready .pl-seq { animation: pl-in .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes pl-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* 14. Reduced motion ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
