/* === Tell the Universe – styles.css (merged) === */
:root{
  /* Purple Cosmic Theme */
  --bg-0:#0c0613;
  --bg-1:#130a22;
  --fg:#eadeff;
  --muted:#b9a6f5;
  --line:rgba(185,127,255,.25);
  --line2:rgba(168,85,247,.35);
  --panel:rgba(28,15,46,.60);
  --panel-2:rgba(28,15,46,.50);
  --accent:#a855f7;
  --accent-2:#c084fc;
  /* Dark UI hint */
  color-scheme: dark;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0; color:var(--fg);
  font-family:"Quicksand", system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size:16px; line-height:1.45;
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;

  /* cosmic gradient */
  background:
    radial-gradient(60% 90% at 50% 0%, var(--bg-1), transparent 60%),
    radial-gradient(70% 120% at 50% 100%, #0a0714, transparent 55%),
    linear-gradient(180deg, #090512 0%, var(--bg-0) 70%);
}
/* reduce overscroll jank */
html, body{ overscroll-behavior: none; }

/* Main column (above floating posts) */
.wrap{
  max-width:400px; margin:0 auto; padding:56px 18px; position:relative; z-index:3;
  /* Respect safe areas (notches) horizontally */
  padding-left: calc(18px + env(safe-area-inset-left));
  padding-right: calc(18px + env(safe-area-inset-right));
  /* Also respect safe areas vertically */
  padding-top:    calc(56px + env(safe-area-inset-top));
  padding-bottom: calc(56px + env(safe-area-inset-bottom));
}

/* Hard cap the visual width of floating posts */
.post{
  max-width: min(var(--post-max-w, 250px), 92vw);
  overflow-wrap: anywhere;   /* prevent long links from stretching the card */
}

/* (optional) clamp lines instead of chopping text in JS */
.post .msg{
  display: -webkit-box;
  -webkit-line-clamp: var(--post-max-lines, 6);
  -webkit-box-orient: vertical;
  overflow: hidden;
}


/* Title + subtitle */
h1{
  margin:0 0 8px; font-size:20px;
  color:#f5eaff;
  text-shadow:0 2px 16px rgba(168,85,247,.25);
  letter-spacing:.3px;
}
.sub{
  color: var(--muted);
  font-size: 10px;    /* <- adjust as you like */
  line-height: 1.4;
}

/* tiny links above the main title, with space from top/right */
.micro-links{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-bottom:6px;
  line-height:1;

  /* space from top and right (respect notches/safe areas) */
  padding-top: calc(8px + env(safe-area-inset-top));
  padding-right: calc(20px + env(safe-area-inset-right));
}

.micro-links a{
  font-size:.78rem;
  font-weight:600;
  color:#cfc7ff;
  opacity:.55;
  text-decoration:none;
  transition:opacity .15s ease, text-decoration-color .15s ease;
  text-underline-offset: 3px;
}

.micro-links a:hover,
.micro-links a:focus{ opacity:.95; text-decoration:underline; }

.micro-links .dot{ color:#cfc7ff; opacity:.35; font-size:.78rem; }

/* small screens – nudge spacing a bit */
@media (max-width:640px){
  .micro-links{
    gap:6px;
    margin-bottom:4px;
    padding-top: calc(6px + env(safe-area-inset-top));
    padding-right: calc(14px + env(safe-area-inset-right));
  }
  .micro-links a, .micro-links .dot{ font-size:.74rem; }

  .wrap{
    padding-top:    calc(32px + env(safe-area-inset-top));
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

/* Composer panel as glass */
#postForm{
  position:relative; z-index:3;
  background:linear-gradient(180deg, var(--panel), var(--panel-2));
  border:1px solid var(--line);
  border-radius:20px;
  padding:16px;
  box-shadow:0 0 22px rgba(168,85,247,.35), 0 0 48px rgba(168,85,247,.15);
  -webkit-backdrop-filter:blur(10px);
  backdrop-filter:blur(10px);
}

/* Inputs */
input, textarea{
  width:100%;
  background:#1a0e2b;
  color:var(--fg);
  border:1px solid rgba(255,255,255,.06);
  outline:none;
  border-radius:14px;
  padding:12px;
  resize:none;
  box-shadow: inset 0 0 0 9999px rgba(255,255,255,0);
}
textarea{ height:120px; }

/* Focus */
input:focus, textarea:focus{
  border-color: rgba(168,85,247,.6);
  box-shadow: 0 0 0 3px rgba(168,85,247,.25), 0 6px 30px rgba(168,85,247,.20);
}

/* Placeholder */
input::placeholder, textarea::placeholder{
  color:#8f77d6; opacity:.95;
}

/* Kill Chrome's white autofill (+states hardened) */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active{
  -webkit-box-shadow: 0 0 0 1000px #1a0e2b inset !important;
  -webkit-text-fill-color: var(--fg) !important;
  caret-color: var(--fg);
}
/* Firefox autofill parity */
input:-moz-autofill{
  box-shadow: 0 0 0 1000px #1a0e2b inset;
  -moz-text-fill-color: var(--fg);
  caret-color: var(--fg);
}

/* Footer row under textarea */
.row{ display:flex; justify-content:space-between; align-items:center; margin-top:10px; }
.muted{ color:var(--muted); font-size:13px; }

/* Primary button */
button{
  border:0; border-radius:16px; background:#8b5cf6; color:white;
  padding:10px 18px; font-weight:700; cursor:pointer;
  box-shadow: 0 8px 24px rgba(139,92,246,.35);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
button:hover{ background:#9a6df8; box-shadow:0 10px 34px rgba(154,109,248,.45); transform:translateY(-1px); }
button:active{ transform:translateY(0); }
button[disabled]{ opacity:.55; cursor:not-allowed; }

/* Floating posts layer */
.feed{
  position:fixed; inset:0; overflow:hidden; pointer-events:none; z-index:2;
}
.feed .post{ z-index:0; }
/* Make the Share button clickable despite pointer-events:none */
.feed .post .post-share{ pointer-events:auto; }

/* --- Rating button & popover --- */
.post .actions { display: flex; align-items: center; gap: .35rem; }
.post .btn-icon { appearance: none; border: 0; background: var(--panel-2);
color: var(--fg); padding: .35rem .5rem; border-radius: .65rem;
line-height: 1; display: inline-flex; align-items: center; gap:.35rem;
cursor: pointer; transition: transform .15s ease, background .2s ease; }
.post .btn-icon:hover { background: var(--panel); }
.post .btn-icon:active { transform: translateY(1px) scale(.98); }
.post .btn-icon .badge { font-size:.8em; opacity:.9; }

.post .rate-pop { position: absolute; z-index: 50; inset: auto auto 100% 0;
transform: translateY(-.4rem); display: none; padding: .35rem .4rem;
background: var(--panel); border: 1px solid var(--line2); border-radius: .9rem;
backdrop-filter: blur(4px); box-shadow: 0 8px 30px rgba(0,0,0,.35);
white-space: nowrap; }
.post .rate-pop.open { display: flex; gap: .2rem; }
.post .rate-pop button { border:0; background: transparent; cursor: pointer;
font-size: 1.15rem; padding: .2rem .28rem; line-height: 1.1; border-radius: .5rem; }
.post .rate-pop button:hover { background: rgba(255,255,255,.07); }

/* small badge tint per rating */
.rate-badge { font-size:.95em; }
.rate-shooting { color: #fff; text-shadow: 0 0 8px rgba(255,255,255,.6); }
.rate-sun { color: #fde047; }
.rate-moon { color: #e0e7ff; }
.rate-heart { color: #60a5fa; }
.rate-hole { color: #94a3b8; }

/* Ensure action area is a positioning context */
.post .actions { position: relative; }

/* Post text */
.post .msg{
  color:#f3eaff;
  max-width:68ch;
  word-break:break-word;
  hyphens:auto;
  text-wrap:pretty;
}

/* Post glass cards */
.post{
  position:absolute;
  padding:12px 14px;
  border-radius:16px;
  background: linear-gradient(180deg, rgba(23,12,34,.85), rgba(20,10,31,.75));
  border:1px solid rgba(255,255,255,.15);
  box-shadow:
    0 0 22px rgba(255,255,255,.30),
    0 0 48px rgba(255,255,255,.15);
  /* GPU-friendly transform + content-visibility perf */
  content-visibility:auto;
  contain-intrinsic-size:120px 220px;
  transform: translate3d(var(--x,0), var(--y,0), 0) scale(var(--s,1)) rotate(var(--rot,0deg));
  will-change: transform;
}

/* Meta line */
.post > .meta{
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
  margin-top: 8px;
}
.post > .meta i{ color:var(--accent-2); font-style:italic; font-weight:600; }
.post > .meta time{ opacity:.9; }

/* Intro pop */
.post.enter{ animation: post-pop .35s ease both; }
@keyframes post-pop{
  from{ opacity:0; transform: translate3d(var(--x,0), var(--y,0), 0) scale(calc(var(--s,1)*.96)) rotate(var(--rot,0deg)); }
  to{   opacity:1; transform: translate3d(var(--x,0), var(--y,0), 0) scale(var(--s,1)) rotate(var(--rot,0deg)); }
}

/* Starfield (behind everything) */
#stars{
  position:fixed; inset:0; pointer-events:none; z-index:1; display:block;
}

/* Header line: title + sound toggle */
.header-line{
  display:flex;
  align-items:baseline;            /* aligns button with headline text */
  justify-content:space-between;   /* title left, button right */
  gap:12px;
  margin-bottom:6px;
  position:relative;
  z-index:3; /* above floating posts */
}
.header-line h1{ margin:0; }

/* ===== Sound toggle (white-only, header variant) ===== */
.header-line .sound-toggle{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border-radius:12px;
  background:rgba(255,255,255,0.10);
  border:1px solid rgba(255,255,255,0.30);
  color:#fff;
  font-weight:700;
  font-size:13px;
  cursor:pointer;
  user-select:none;
  pointer-events:auto;
  box-shadow:0 6px 18px rgba(255,255,255,0.18);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}
.header-line .sound-toggle:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.40);
  box-shadow: 0 10px 26px rgba(255,255,255,0.24);
}
.header-line .sound-toggle:active{ transform: translateY(0); }
.header-line .sound-toggle:focus-visible{
  outline: none;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.75), 0 10px 26px rgba(255,255,255,0.24);
}

/* Dot: white-only; ON = brighter white, OFF = dimmer white */
.header-line .sound-toggle .dot{
  width:10px; height:10px; border-radius:50%;
  background: rgba(255,255,255,0.55);  /* OFF */
  box-shadow: 0 0 8px rgba(255,255,255,0.35);
  transition: background .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.header-line .sound-toggle.on .dot{
  background:#ffffff;               /* ON */
  box-shadow:0 0 10px rgba(255,255,255,0.85), 0 0 18px rgba(255,255,255,0.60);
}

/* Label opacity cue */
.header-line .sound-toggle .label{ opacity:.85; }
.header-line .sound-toggle.on .label{ opacity:1; }

/* Motion preference: reduce extra motion for sensitive users */
@media (prefers-reduced-motion: reduce){
  .post.enter{ animation:none; }
  .header-line .sound-toggle,
  button{ transition:none; }
}

/* Android-only compact UI (tighter) */
html.is-android { font-size: 13.5px; }
@media (max-width: 540px){ html.is-android { font-size: 12.5px; } }

.is-android .wrap{
  max-width: 400px;
  padding: 32px 14px;
}

.is-android h1{
  font-size: 15px;
  letter-spacing: .15px;
  text-shadow: 0 2px 14px rgba(168,85,247,.20);
  margin-bottom: 6px;
}

.is-android #postForm{
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 0 14px rgba(168,85,247,.26), 0 0 28px rgba(168,85,247,.10);
}

.is-android input,
.is-android textarea{
  border-radius: 9px;
  padding: 8px;
  font-size: 13px;
}
.is-android textarea{ height: 88px; }

.is-android .row{ margin-top: 6px; } /* fixed stray “720p” token */
.is-android .muted{ font-size: 11.5px; }

.is-android button{
  border-radius: 12px;
  padding: 7px 12px;
  font-size: 12px;
  box-shadow: 0 5px 14px rgba(139,92,246,.26);
}

.is-android .header-line .sound-toggle{
  padding: 5px 9px;
  font-size: 11px;
  border-radius: 9px;
  box-shadow: 0 4px 12px rgba(255,255,255,0.14);
}
.is-android .sound-toggle .dot{ width: 7px; height: 7px; }

.is-android .post{
  padding: 8px 10px;
  border-radius: 12px;
  box-shadow:
    0 0 14px rgba(255,255,255,.22),
    0 0 28px rgba(255,255,255,.10);
}
.is-android .post > .meta{ font-size: 8.5px; }

/* ======================= iOS-only compact UI (same as Android) ======================= */
html.is-ios { font-size: 13.5px; }
@media (max-width: 540px){ html.is-ios { font-size: 12.5px; } }

.is-ios .wrap{
  max-width: 400px;
  padding: 32px 14px;
}

.is-ios h1{
  font-size: 15px;
  letter-spacing: .15px;
  text-shadow: 0 2px 14px rgba(168,85,247,.20);
  margin-bottom: 6px;
}

.is-ios #postForm{
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 0 14px rgba(168,85,247,.26), 0 0 28px rgba(168,85,247,.10);
}

.is-ios input,
.is-ios textarea{
  border-radius: 9px;
  padding: 8px;
  font-size: 13px;
}
.is-ios textarea{ height: 88px; }

.is-ios .row{ margin-top: 6px; }
.is-ios .muted{ font-size: 11.5px; }

.is-ios button{
  border-radius: 12px;
  padding: 7px 12px;
  font-size: 12px;
  box-shadow: 0 5px 14px rgba(139,92,246,.26);
}

.is-ios .header-line .sound-toggle{
  padding: 5px 9px;
  font-size: 11px;
  border-radius: 9px;
  box-shadow: 0 4px 12px rgba(255,255,255,0.14);
}
.is-ios .sound-toggle .dot{ width: 7px; height: 7px; }

.is-ios .post{
  padding: 8px 10px;
  border-radius: 12px;
  box-shadow:
    0 0 14px rgba(255,255,255,.22),
    0 0 28px rgba(255,255,255,.10);
}
.is-ios .post > .meta{ font-size: 8.5px; }

/* Selection color consistent with theme */
::selection{ background: rgba(168,85,247,.35); color: #fff; }

/* Accessibility fallback if any element lacks strong focus styles */
:focus-visible{
  outline: 2px solid rgba(168,85,247,.75);
  outline-offset: 2px;
}

/* Backdrop-filter fallback for older browsers (outside feature block too) */
@supports not ((backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px))) {
  #postForm {
    background: linear-gradient(180deg, rgba(28,15,46,.85), rgba(28,15,46,.70));
  }
}

/* === Essentials patch (append at end) === */

/* Prevent elastic overscroll jank */
html, body { overscroll-behavior: none; }

/* Share button remains clickable despite .feed { pointer-events:none } */
.feed .post .post-share { pointer-events: auto; }

/* Long-text safety in floating posts */
.post .msg {
  max-width: 68ch;
  word-break: break-word;
  hyphens: auto;
  text-wrap: pretty;
}

/* Performance: offscreen cards */
.post {
  content-visibility: auto;
  contain-intrinsic-size: 120px 220px;
  transform: translate3d(var(--x,0), var(--y,0), 0)
             scale(var(--s,1)) rotate(var(--rot,0deg));
}

/* Themed text selection */
::selection { background: rgba(168,85,247,.35); color: #fff; }

/* Higher contrast when requested */
@media (prefers-contrast: more){
  #postForm { border-color: rgba(168,85,247,.55); }
  .post { border-color: rgba(255,255,255,.28); }
}

/* Backdrop-filter fallback (older browsers) */
@supports not ((backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px))){
  #postForm {
    background: linear-gradient(180deg, rgba(28,15,46,.85), rgba(28,15,46,.70));
  }
}

/* Firefox autofill parity */
input:-moz-autofill{
  box-shadow: 0 0 0 1000px #1a0e2b inset;
  -moz-text-fill-color: var(--fg);
  caret-color: var(--fg);
}

/* ===== Mobile font sizing for floating posts (override-at-end) ===== */
@media (max-width: 640px){
  .post{ font-size: 0.95rem; line-height: 1.35; }
  .post .msg{ line-height: 1.35; }
  .post > .meta{ font-size: 9px; }
}
@media (max-width: 420px){
  .post{ font-size: 0.90rem; }
  .post .msg{ line-height: 1.3; }
  .post > .meta{ font-size: 7px; }
}
