/* Tape Deck Focus — Stick Timer
   warm paper, washi, marker scribbles */

:root {
  --paper: #F6EFE4;
  --ink: #1C1917;
  --hot: #FF6B4A;
  --cool: #7DD3C0;
  --hi: #F5E663;
  --sticky: #FFF8E7;
  --tape: rgba(125, 211, 192, 0.55);
  --tape-alt: rgba(245, 230, 99, 0.55);
  --shadow: rgba(28, 25, 23, 0.12);
  --radius: 4px;
  --rotate: -1.2deg;
  --font-ui: "DM Sans", system-ui, sans-serif;
  --font-display: "Caveat", cursive;
}

/* Theme skins (unlocked) */
body[data-theme="hot"] {
  --sticky: #FFE8E2;
  --tape: rgba(255, 107, 74, 0.45);
  --tape-alt: rgba(255, 107, 74, 0.3);
}

body[data-theme="cool"] {
  --sticky: #E8F8F4;
  --tape: rgba(125, 211, 192, 0.65);
  --tape-alt: rgba(125, 211, 192, 0.35);
}

body[data-theme="highlighter"] {
  --sticky: #FFFCE8;
  --tape: rgba(245, 230, 99, 0.7);
  --tape-alt: rgba(255, 107, 74, 0.35);
}

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

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.4;
  position: relative;
  overflow-x: hidden;
}

/* Soft paper grain */
.paper-grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.top-bar,
.stage,
.foot {
  position: relative;
  z-index: 1;
}

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem 0.5rem;
  max-width: 720px;
  margin: 0 auto;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.02em;
  line-height: 1;
}

.brand-mark {
  display: inline-block;
  color: var(--hot);
  font-size: 1.25rem;
  margin-right: 0.25rem;
  transform: rotate(-8deg);
}

.tagline {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  opacity: 0.7;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.65rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.icon-btn:hover {
  background: rgba(28, 25, 23, 0.06);
}

.icon-btn[aria-pressed="true"] {
  background: var(--cool);
  border-color: var(--ink);
}

.icon-btn:focus-visible,
.preset-btn:focus-visible,
.big-btn:focus-visible,
.apply-btn:focus-visible,
.theme-btn:focus-visible,
.unlock-link:focus-visible {
  outline: 3px solid var(--hot);
  outline-offset: 2px;
}

.unlock-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border: 2px dashed var(--ink);
  border-radius: 999px;
  background: var(--hi);
  transition: transform 0.1s, background 0.15s;
}

.unlock-link:hover {
  transform: rotate(-1deg) scale(1.02);
  background: #f8ed4a;
}

body.is-unlocked .unlock-link {
  display: none;
}

.stage {
  max-width: 420px;
  margin: 1.5rem auto 2rem;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

/* Washi / masking tape strips */
.tape {
  width: 140px;
  height: 22px;
  background: var(--tape);
  box-shadow: 0 1px 2px var(--shadow);
  transform: rotate(-2deg);
  border-radius: 1px;
  position: relative;
  z-index: 2;
}

.tape::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 8px,
    rgba(255, 255, 255, 0.25) 8px,
    rgba(255, 255, 255, 0.25) 10px
  );
  opacity: 0.6;
}

.tape-top {
  margin-bottom: -18px;
}

.tape-bottom {
  margin-top: -18px;
  width: 100px;
  background: var(--tape-alt);
  transform: rotate(3deg);
}

/* The sticky note */
.sticky {
  width: 100%;
  max-width: 340px;
  min-height: 280px;
  background: var(--sticky);
  padding: 2rem 1.5rem 1.5rem;
  border-radius: var(--radius);
  box-shadow:
    2px 4px 0 rgba(28, 25, 23, 0.06),
    4px 12px 28px var(--shadow);
  transform: rotate(var(--rotate));
  position: relative;
  text-align: center;
  transition: background 0.25s;
}

.sticky::before {
  /* slight curl / edge */
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 28px;
  height: 28px;
  background: linear-gradient(225deg, rgba(28, 25, 23, 0.08) 0%, transparent 55%);
  border-radius: 0 var(--radius) 0 0;
  pointer-events: none;
}

.washi {
  position: absolute;
  height: 18px;
  border-radius: 1px;
  pointer-events: none;
}

.washi-a {
  width: 72px;
  top: 12px;
  left: -8px;
  background: var(--tape);
  transform: rotate(-8deg);
  opacity: 0.9;
}

.washi-b {
  width: 56px;
  top: 8px;
  right: 20px;
  background: var(--tape-alt);
  transform: rotate(12deg);
  opacity: 0.85;
}

.mode-label {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0.5rem 0 0;
  opacity: 0.65;
  letter-spacing: 0.04em;
}

.time-display {
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 18vw, 6.5rem);
  font-weight: 700;
  line-height: 1;
  margin: 0.25rem 0 0.75rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.4);
}

.note-wrap {
  display: block;
  text-align: left;
  margin-top: 0.5rem;
}

.note-heading {
  display: block;
  font-family: var(--font-display);
  font-size: 1.1rem;
  opacity: 0.7;
  margin-bottom: 0.25rem;
}

#noteSelf {
  width: 100%;
  resize: none;
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.3;
  border: none;
  background: transparent;
  color: var(--ink);
  border-bottom: 2px dashed rgba(28, 25, 23, 0.2);
  padding: 0.25rem 0;
}

#noteSelf:focus {
  outline: none;
  border-bottom-color: var(--hot);
}

#noteSelf::placeholder {
  opacity: 0.4;
}

.sessions {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0.75;
}

.sessions span {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--hot);
}

/* Controls */
.controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: center;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.preset-btn {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--shadow);
  transition: transform 0.1s, background 0.15s;
}

.preset-btn:hover {
  transform: translate(-1px, -1px);
}

.preset-btn[aria-pressed="true"] {
  background: var(--cool);
}

.custom-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.45);
  border: 2px dashed rgba(28, 25, 23, 0.2);
  border-radius: 10px;
}

.custom-row label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: lowercase;
  opacity: 0.8;
}

.custom-row input {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  width: 5.5rem;
  padding: 0.4rem 0.5rem;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.apply-btn {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.45rem 0.85rem;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--hi);
  cursor: pointer;
}

.transport {
  display: flex;
  gap: 0.65rem;
  width: 100%;
  max-width: 320px;
}

.big-btn {
  flex: 1;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  padding: 0.65rem 1rem;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.1s, box-shadow 0.1s;
}

.big-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.big-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink);
}

.big-btn.primary {
  background: var(--hot);
  color: #fff;
}

.big-btn.primary.is-running {
  background: var(--cool);
  color: var(--ink);
}

.theme-bar {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.theme-heading {
  font-family: var(--font-display);
  font-size: 1.15rem;
  opacity: 0.7;
  margin-right: 0.25rem;
}

.theme-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.theme-btn {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

.theme-btn[aria-pressed="true"] {
  background: var(--hi);
}

.theme-btn[data-theme="hot"][aria-pressed="true"] {
  background: var(--hot);
  color: #fff;
}

.theme-btn[data-theme="cool"][aria-pressed="true"] {
  background: var(--cool);
}

[hidden] {
  display: none !important;
}

.unlocked-only {
  display: none !important;
}

body.is-unlocked .unlocked-only {
  display: block !important;
}

body.is-unlocked .theme-bar.unlocked-only {
  display: flex !important;
}

body.is-unlocked .note-wrap.unlocked-only {
  display: block !important;
}

body.is-unlocked .sessions.unlocked-only {
  display: block !important;
}

.foot {
  text-align: center;
  padding: 0 1rem 2rem;
  font-size: 0.8rem;
  opacity: 0.55;
}

.foot p {
  margin: 0;
}

/* —— Stream / OBS mode —— */
body.stream-mode {
  background: var(--paper);
}

body.stream-mode .paper-grain {
  opacity: 0.2;
}

body.stream-mode .top-bar,
body.stream-mode .controls,
body.stream-mode .theme-bar,
body.stream-mode .foot,
body.stream-mode .tape {
  display: none !important;
}

body.stream-mode .stage {
  max-width: none;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  justify-content: center;
}

body.stream-mode .sticky {
  max-width: min(520px, 90vw);
  min-height: auto;
  padding: 2.5rem 2rem;
  transform: rotate(-0.6deg);
  box-shadow:
    3px 6px 0 rgba(28, 25, 23, 0.05),
    8px 20px 40px var(--shadow);
}

body.stream-mode .time-display {
  font-size: clamp(5rem, 14vw, 8rem);
}

body.stream-mode .mode-label {
  font-size: 1.75rem;
}

body.stream-mode .note-wrap,
body.stream-mode .sessions {
  /* keep note + count visible for stream if unlocked */
}

/* Mobile */
@media (max-width: 480px) {
  .top-bar {
    padding: 1rem 1rem 0.25rem;
  }

  .brand h1 {
    font-size: 1.65rem;
  }

  .btn-label {
    /* keep short labels */
  }

  .sticky {
    min-height: 240px;
    padding: 1.75rem 1.25rem 1.25rem;
  }

  .big-btn {
    font-size: 1.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .preset-btn,
  .big-btn,
  .unlock-link,
  .icon-btn {
    transition: none;
  }
}


/* Exit control — hidden unless stream mode (top bar is hidden there) */
.exit-stream {
  display: none;
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 20;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--shadow);
}

body.stream-mode .exit-stream {
  display: inline-flex;
  align-items: center;
}

body.stream-mode .exit-stream:hover {
  background: var(--hi);
}

body.stream-mode .exit-stream:focus-visible {
  outline: 3px solid var(--hot);
  outline-offset: 2px;
}
