/* =========================================================
   3分日記 / three minute journal
   palette: 藍 (indigo ink) + 薄金 (pale gold), cream paper
   style:   研究ノート (ruled research notebook)
   ========================================================= */

:root {
  /* paper & ink */
  --paper:       #f6f1e4;
  --paper-card:  #fbf8f0;
  --paper-edge:  #ece3cf;
  --ink:         #1d2742;   /* 藍 */
  --ink-soft:    #404c6e;
  --ink-faint:   #8089a0;

  /* gold */
  --gold:        #b78b34;   /* 薄金 */
  --gold-soft:   #cdaa5e;
  --gold-pale:   #e8d6a8;

  /* ruled lines */
  --rule:        rgba(29, 39, 66, 0.13);
  --rule-strong: rgba(29, 39, 66, 0.28);
  --margin-line: rgba(183, 139, 52, 0.45);

  --ok:          #3f7d63;
  --warn:        #b5562f;

  --radius:      14px;
  --radius-sm:   9px;
  --shadow:      0 18px 40px -28px rgba(20, 28, 52, 0.55);
  --shadow-soft: 0 8px 22px -16px rgba(20, 28, 52, 0.5);

  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --sans:  "Hiragino Kaku Gothic ProN", "Yu Gothic", "YuGothic", "Meiryo", system-ui, sans-serif;
  --num:   ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: #ece3cf;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Page backdrop — image with graceful cream fallback */
.paper {
  min-height: 100vh;
  padding: clamp(14px, 4vw, 48px) 14px clamp(40px, 6vw, 72px);
  background-color: var(--paper);
  background-image:
    radial-gradient(120% 90% at 80% -10%, rgba(232, 214, 168, 0.55), transparent 55%),
    radial-gradient(120% 80% at -10% 10%, rgba(29, 39, 66, 0.06), transparent 45%),
    url("../assets/background.png");
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-size: cover, cover, cover;
  background-position: center top, center, center top;
}

/* The single vertical notebook sheet */
.notebook {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) clamp(18px, 4vw, 44px) clamp(28px, 4vw, 44px);
  background: var(--paper-card);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
  /* faint horizontal ruled lines, like a research notebook */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 33px,
    var(--rule) 33px,
    var(--rule) 34px
  );
  background-position: 0 6px;
}

/* gold margin line on the left like a notebook */
.notebook::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: clamp(12px, 3vw, 28px);
  width: 1.5px;
  background: var(--margin-line);
  opacity: 0.7;
  pointer-events: none;
}

/* ===================== Masthead ===================== */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.masthead__kicker {
  font-family: var(--num);
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--gold);
}

.masthead__title {
  font-family: var(--serif);
  font-size: clamp(30px, 7vw, 46px);
  margin: 2px 0 4px;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.masthead__date {
  margin: 0;
  font-family: var(--num);
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}

/* ---- Timer dial ---- */
.timer {
  position: relative;
  width: clamp(92px, 22vw, 116px);
  height: clamp(92px, 22vw, 116px);
  flex: none;
}
.timer__dial { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer__track {
  fill: none;
  stroke: var(--rule-strong);
  stroke-width: 5;
  opacity: 0.5;
}
.timer__progress {
  fill: none;
  stroke: var(--gold);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 326.7;        /* 2*pi*52 */
  stroke-dashoffset: 326.7;        /* empty at start */
  transition: stroke-dashoffset 0.9s linear, stroke 0.4s ease;
}
.timer.is-overtime .timer__progress { stroke: var(--ink-soft); }
.timer__readout {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1px;
}
.timer__time {
  font-family: var(--num);
  font-size: clamp(18px, 4.6vw, 23px);
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.timer__label {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}
.timer.is-running .timer__label { color: var(--gold); }

.masthead__rule {
  height: 2px;
  margin: 14px 0 10px;
  background: linear-gradient(to right, var(--ink) 0 64px, var(--rule) 64px);
  opacity: 0.8;
}

.statusbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.statusbar__save {
  font-family: var(--num);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  padding: 2px 0;
}
.statusbar__save.is-dirty { color: var(--warn); }
.statusbar__save.is-saved { color: var(--ok); }

.timer__controls { display: flex; gap: 8px; }

.chip {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--ink-soft);
  background: var(--paper-card);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.18s ease;
}
.chip:hover { border-color: var(--gold); color: var(--gold); }
.chip--ghost { border-color: var(--rule-strong); color: var(--ink-faint); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper-card); }

/* ===================== Intro / empty state ===================== */
.intro {
  text-align: center;
  padding: clamp(14px, 3vw, 24px) 4px clamp(18px, 3vw, 26px);
  margin: 8px 0 18px;
  border: 1px dashed var(--margin-line);
  border-radius: var(--radius);
  background: rgba(251, 248, 240, 0.6);
}
.intro__art { margin: 0 auto 14px; max-width: 360px; }
.intro__art img {
  width: 100%; height: auto; display: block;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
}
.intro__art-fallback { display: none; }
.intro__art--fallback .intro__art-fallback {
  display: flex; justify-content: center; gap: clamp(20px, 8vw, 48px);
  padding: 22px 0;
}
.intro__art--fallback .glyph {
  width: clamp(58px, 18vw, 78px); height: clamp(58px, 18vw, 78px);
  display: grid; place-items: center;
  font-size: clamp(22px, 6vw, 30px);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  background: var(--paper-card);
  box-shadow: var(--shadow-soft);
  color: var(--gold);
}
.intro__title {
  font-family: var(--serif);
  font-size: clamp(20px, 5vw, 26px);
  margin: 0 0 8px;
  font-weight: 600;
}
.intro__lead { margin: 0 0 18px; color: var(--ink-soft); font-size: 15px; }

/* ===================== Question cards ===================== */
.prompts { margin: 4px 0 0; }
.prompts__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }

.qcard {
  background: var(--paper-card);
  border: 1px solid var(--paper-edge);
  border-left: 3px solid var(--gold-pale);
  border-radius: var(--radius-sm);
  padding: 16px 18px 12px;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.qcard:focus-within {
  border-left-color: var(--gold);
  box-shadow: 0 12px 26px -18px rgba(20, 28, 52, 0.6);
}
.qcard--accent { border-left-color: var(--gold); background: linear-gradient(180deg, #fcf7e9, var(--paper-card)); }

.qcard__head { display: flex; align-items: flex-start; gap: 12px; }
.qcard__no {
  font-family: var(--num);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--gold);
  padding-top: 4px;
}
.qcard__icon {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  font-size: 17px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 50%;
}
.qcard__title-wrap { flex: 1; min-width: 0; }
.qcard__title {
  font-family: var(--serif);
  font-size: 18px;
  margin: 2px 0 2px;
  font-weight: 600;
}
.qcard__hint { margin: 0; font-size: 12.5px; color: var(--ink-faint); }

.qcard__input {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  resize: vertical;
  transition: border-color 0.18s ease, background 0.18s ease;
  /* faint ruling inside the field */
  background-image: repeating-linear-gradient(
    to bottom, transparent 0 26px, var(--rule) 26px 27px);
  background-attachment: local;
}
.qcard__input::placeholder { color: var(--ink-faint); opacity: 0.7; }
.qcard__input:focus {
  outline: none;
  border-color: var(--gold);
  background-color: #fffdf7;
}

.moodrow { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.mood {
  font-family: var(--sans);
  font-size: 12.5px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--paper-edge);
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.16s ease;
}
.mood:hover { border-color: var(--gold-soft); }
.mood.is-on { background: var(--ink); border-color: var(--ink); color: var(--paper-card); }

.qcard__count {
  display: block;
  text-align: right;
  margin-top: 6px;
  font-family: var(--num);
  font-size: 11px;
  color: var(--ink-faint);
}

.prompts__actions {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin: 22px 0 6px;
}

/* ===================== Buttons ===================== */
.btn {
  font-family: var(--sans);
  font-size: 15px;
  letter-spacing: 0.03em;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--ink);
  color: var(--paper-card);
  box-shadow: 0 12px 24px -16px rgba(20, 28, 52, 0.8);
}
.btn--primary:hover { background: #27345a; box-shadow: 0 14px 28px -14px rgba(20, 28, 52, 0.85); }
.btn--ghost {
  background: transparent;
  border-color: var(--rule-strong);
  color: var(--ink-soft);
}
.btn--ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn--share {
  background: var(--gold);
  color: #2a2008;
  box-shadow: 0 12px 24px -16px rgba(183, 139, 52, 0.9);
}
.btn--share:hover { background: var(--gold-soft); }
.btn--danger { background: var(--warn); color: #fff; }
.btn--danger:hover { background: #9c4827; }

/* ===================== Saved tomorrow-step card ===================== */
.stepcard {
  margin: 20px 0 6px;
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 0;
  border: 1px solid var(--gold-pale);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: linear-gradient(120deg, #fcf6e6, var(--paper-card));
  animation: rise 0.5s ease both;
}
.stepcard__art { position: relative; min-height: 120px; background: #efe7d2; }
.stepcard__art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stepcard__art.is-fallback {
  background:
    radial-gradient(circle at 70% 35%, rgba(232, 214, 168, 0.9), transparent 60%),
    linear-gradient(180deg, #f2ead7, #e7ddc5);
}
.stepcard__art.is-fallback::after {
  content: "❦";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 34px; color: var(--gold);
}
.stepcard__body { padding: 16px 20px; }
.stepcard__label {
  font-family: var(--num);
  font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--gold);
}
.stepcard__text {
  font-family: var(--serif);
  font-size: clamp(17px, 4.4vw, 21px);
  line-height: 1.6;
  margin: 6px 0 10px;
  color: var(--ink);
}
.stepcard__foot { font-size: 12px; color: var(--ink-faint); }

@media (max-width: 520px) {
  .stepcard { grid-template-columns: 1fr; }
  .stepcard__art { min-height: 96px; }
}

/* ===================== History ===================== */
.history { margin-top: 30px; }
.history__head {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 2px solid var(--rule-strong);
  padding-bottom: 6px; margin-bottom: 12px;
}
.history__title { font-family: var(--serif); font-size: 19px; margin: 0; font-weight: 600; }
.history__count { font-family: var(--num); font-size: 12px; color: var(--ink-faint); }

.history__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hentry {
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  background: var(--paper-card);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}
.hentry:hover { border-color: var(--gold-soft); box-shadow: var(--shadow-soft); transform: translateX(2px); }
.hentry__top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.hentry__date { font-family: var(--num); font-size: 13px; color: var(--ink); letter-spacing: 0.06em; }
.hentry__weekday { font-size: 11px; color: var(--ink-faint); }
.hentry__today {
  margin-left: auto;
  font-size: 10px; letter-spacing: 0.1em;
  padding: 2px 8px; border-radius: 999px;
  background: var(--gold-pale); color: #5d4710;
}
.hentry__snippet {
  font-size: 13.5px; color: var(--ink-soft);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.hentry__step { margin-top: 6px; font-size: 12.5px; color: var(--gold); }
.hentry__step::before { content: "❦ "; }

.history__empty {
  text-align: center; color: var(--ink-faint); font-size: 14px;
  padding: 22px 8px; border: 1px dashed var(--margin-line); border-radius: var(--radius-sm);
}

/* ===================== Share ===================== */
.share {
  margin-top: 30px;
  padding: 20px;
  text-align: center;
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  background:
    radial-gradient(100% 120% at 50% -20%, rgba(232, 214, 168, 0.4), transparent 60%),
    var(--paper-card);
}
.share__lead { margin: 0 0 14px; font-family: var(--serif); font-size: 16px; }
.share__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.share__url { margin: 12px 0 0; font-family: var(--num); font-size: 11.5px; color: var(--ink-faint); word-break: break-all; }

/* ===================== Colophon ===================== */
.colophon { margin-top: 26px; text-align: center; color: var(--ink-faint); font-size: 12px; }
.colophon p { margin: 4px 0; }
.colophon__sig { font-family: var(--num); letter-spacing: 0.14em; }

/* ===================== Modal ===================== */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; }
.modal[hidden] { display: none; }
.modal__scrim { position: absolute; inset: 0; background: rgba(20, 26, 46, 0.45); backdrop-filter: blur(2px); }
.modal__panel {
  position: relative;
  width: min(440px, 100%);
  background: var(--paper-card);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  box-shadow: 0 28px 60px -24px rgba(12, 18, 38, 0.7);
  padding: 22px 22px 18px;
  animation: rise 0.28s ease both;
}
.modal__title { font-family: var(--serif); font-size: 19px; margin: 0 0 10px; }
.modal__body { font-size: 14.5px; color: var(--ink-soft); line-height: 1.75; }
.modal__body .detail-field { margin: 12px 0; }
.modal__body .detail-field h4 {
  margin: 0 0 3px; font-size: 12px; color: var(--gold);
  font-family: var(--num); letter-spacing: 0.12em;
}
.modal__body .detail-field p {
  margin: 0; color: var(--ink); white-space: pre-wrap;
  background: var(--paper); border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.modal__actions .btn { padding: 9px 18px; font-size: 14px; }

/* ===================== Toast ===================== */
.toast-stack {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 8px;
  width: min(420px, calc(100% - 28px)); pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--ink);
  color: var(--paper-card);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 14px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px;
  animation: toast-in 0.3s ease both;
}
.toast.is-out { animation: toast-out 0.3s ease forwards; }
.toast__mark { color: var(--gold-soft); font-size: 15px; }
.toast--warn { background: var(--warn); }
.toast--warn .toast__mark { color: #ffe2cf; }

/* ===================== Motion ===================== */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(14px); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ===================== Narrow screens ===================== */
@media (max-width: 480px) {
  .notebook { padding: 18px 16px 24px; }
  .masthead { gap: 10px; }
  .timer { order: -1; }
  .prompts__actions .btn, .share__actions .btn { flex: 1 1 auto; }
}
