/* SECRET 8 CODE — Four Pillars calendar */

:root {
  --cream: #faf3e2;
  --paper: #fffaf0;
  --navy: #151a35;
  --ink: #2b2f45;
  --muted: #6b6a73;
  --line: #d9d0c3;
  --green: #3f7b5e;
  --red: #c8573f;
  --gold: #d8b068;
  --gold-dark: #b8914a;
  --stone: #e9e3d8;
  --plum: #4a3566;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.5;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.page {
  width: 100%;
  max-width: 560px;
  padding: 28px 16px 40px;
}

/* Header */
.brand {
  text-align: center;
  margin-bottom: 24px;
}
.brand img {
  width: 132px;
  height: 132px;
}
.brand h1 {
  font-family: 'Josefin Sans', sans-serif;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--navy);
  font-size: 26px;
  margin: 10px 0 4px;
}
.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* Card */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 20px;
  box-shadow: 0 6px 20px rgba(21, 26, 53, 0.06);
}

.field { margin-bottom: 18px; }
.field > label,
.field > .label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--navy);
  margin-bottom: 6px;
}
.hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

input[type="text"],
input[type="number"],
input[type="time"],
select {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  appearance: none;
}
input:focus, select:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
input:disabled { background: var(--stone); color: var(--muted); }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.row > .year { flex: 1.3; }

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 10px;
  font-size: 15px;
}
.choices label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.choices input { accent-color: var(--navy); width: 17px; height: 17px; }

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 15px;
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.03em;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease;
}
.btn-primary { background: var(--navy); color: var(--cream); }
.btn-primary:hover { background: #262d55; }
.btn-primary:disabled { background: var(--muted); cursor: wait; }
/* Plum: a color none of the five elements use */
.btn-whatsapp { background: var(--plum); color: #fff; }
.btn-whatsapp:hover { background: #3b2a52; }
.btn-ghost {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--line);
  margin-top: 12px;
}
.btn-ghost:hover { background: var(--stone); }

.error {
  display: none;
  background: #fbe9e4;
  color: #8f3320;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  margin-bottom: 14px;
}
.error.show { display: block; }

footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 16px;
}
footer a {
  color: var(--navy);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* Result */
.person {
  text-align: center;
  margin-bottom: 18px;
}
.person h2 {
  font-family: 'Josefin Sans', sans-serif;
  color: var(--navy);
  font-size: 24px;
  margin: 0 0 6px;
}
.person .dates {
  font-size: 15px;
  color: var(--muted);
}

.chart {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  align-items: stretch;
}
.chart .head {
  font-family: 'Josefin Sans', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.05em;
  text-align: center;
  color: var(--navy);
  padding: 4px 0;
}
.tile {
  border-radius: 10px;
  aspect-ratio: 1 / 1.15;
  /* keep long names from stretching the tile past its column */
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
  border: 2px solid rgba(21, 26, 53, 0.12);
}
/* The English name leads; the Chinese character is a small accent above it */
.tile .han {
  font-family: 'Noto Serif KR', serif;
  font-weight: 700;
  font-size: 36px;
  line-height: 1;
  opacity: 0.9;
}
.tile .en {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.15;
  margin-top: 6px;
  white-space: nowrap;
}
.tile .en.long { font-size: clamp(11px, 3.4vw, 14px); }
.tile.wood  { background: var(--green); color: #fff; }
.tile.fire  { background: var(--red);   color: #fff; }
.tile.earth { background: var(--gold);  color: var(--navy); }
.tile.metal { background: #f4f1ea;      color: var(--navy); border-color: var(--line); }
.tile.water { background: var(--navy);  color: var(--cream); }
.tile.unknown { background: transparent; color: var(--muted); border-style: dashed; }
.tile.unknown .han { font-size: 24px; }

/* Day Master marker */
.chart .marker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-align: center;
  color: var(--navy);
  min-height: 26px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.chart .marker.me {
  background: var(--plum);
  color: #fff;
  border-radius: 8px 8px 0 0;
  padding: 4px 2px;
  margin-bottom: -6px;
}
.tile.me {
  outline: 3px solid var(--plum);
  outline-offset: 0;
}

/* Reveal: tiles rise in one by one, then "This is you" drops onto the Day Master.
   CSS only, so nothing extra to download. */
@keyframes tileIn {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to   { opacity: 1; transform: none; }
}
@keyframes markerIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: none; }
}
.tile { animation: tileIn 0.45s ease-out both; animation-delay: var(--d, 0s); }
/* After settling in, "This is you" floats very softly */
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2px); }
}
/* Marker and Day Master tile share the same float so they move as one */
.chart .marker.me { animation: markerIn 0.5s ease-out 0.95s both, bob 2.8s ease-in-out 1.5s infinite; }
.tile.me { animation: tileIn 0.45s ease-out var(--d, 0s) both, bob 2.8s ease-in-out 1.5s infinite; }
/* Loading overlay with the five-element ring */
.loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(250, 243, 226, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.loading[hidden] { display: none; }
.loading p {
  margin: 0;
  font-family: 'Josefin Sans', sans-serif;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--navy);
}
.ring { width: 110px; height: 110px; animation: spin 1.6s linear infinite; }
.ring circle {
  fill: none;
  stroke-width: 9;
  stroke-dasharray: 44 207.33;
  stroke-linecap: butt;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Booking button: a soft "breathing" glow after the chart has revealed */
@keyframes breathe {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(74, 53, 102, 0.35); }
  50%      { transform: scale(1.03); box-shadow: 0 0 0 8px rgba(74, 53, 102, 0); }
}
.btn-whatsapp { animation: breathe 2.6s ease-in-out 1.6s infinite; }

@media (prefers-reduced-motion: reduce) {
  .tile, .tile.me, .chart .marker.me, .btn-whatsapp { animation: none; }
  .ring { animation-duration: 4s; }
}

.me-line {
  text-align: center;
  font-size: 16px;
  margin: 18px 0 0;
  color: var(--ink);
}
.me-line strong { color: var(--navy); }

.legend {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  margin-top: 14px;
  white-space: nowrap;
}

/* Logo medal at the bottom of the result page */
.medal {
  display: block;
  width: 72px;
  margin: 24px auto 0;
}
.medal img { width: 72px; height: 72px; display: block; }
.legend span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: -1px;
  border: 1px solid rgba(21, 26, 53, 0.2);
}
.legend .wood::before  { background: var(--green); }
.legend .fire::before  { background: var(--red); }
.legend .earth::before { background: var(--gold); }
.legend .metal::before { background: #f4f1ea; }
.legend .water::before { background: var(--navy); }

.cta {
  margin-top: 20px;
  text-align: center;
}
.cta h3 {
  font-family: 'Josefin Sans', sans-serif;
  color: var(--navy);
  font-size: 19px;
  margin: 0 0 6px;
}
.cta p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
}

/* Phones */
@media (max-width: 480px) {
  .page { padding-top: 20px; }
  .card { padding: 18px 12px; }
  .chart .marker { font-size: 11.5px; white-space: nowrap; }
  .tile { aspect-ratio: auto; height: clamp(100px, 30vw, 118px); padding: 6px 3px; }
  .tile .han { font-size: clamp(28px, 8.5vw, 34px); }
  .tile .en { font-size: clamp(13px, 4vw, 16px); margin-top: 5px; }
  .legend { gap: 8px; font-size: 12px; }
  .legend span::before { margin-right: 3px; }
  .person h2 { font-size: 21px; }
  .person .dates { font-size: 14px; }
}

/* Very small phones (e.g. iPhone SE 1st gen): a little more room for long names */
@media (max-width: 340px) {
  .page { padding-left: 10px; padding-right: 10px; }
  .card { padding: 16px 8px; }
  .chart { gap: 4px; }
  .chart .marker { font-size: 10px; }
  .brand img { width: 96px; height: 96px; }
  .brand h1 { font-size: 22px; }
  .row { gap: 6px; }
  select { padding-left: 9px; padding-right: 22px; background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%; }
}
