/* Same colours as the apps: saffron, kumkum red, green for good, red for avoid */
:root {
  --bg: #f2f2f7; --card: #fff; --text: #1c1c1e; --muted: #6e6e73; --line: #e5e5ea;
  --accent: #cc381a; --saffron: #f58c21; --good: #218c4d; --bad: #bf2633;
  --sun: #fff6eb; --moon: #f1f1fb; --chip: #ece6f0;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --card: #1c1c1e; --text: #f2f2f7; --muted: #aeaeb2; --line: #2c2c2e;
          --accent: #f08a5d; --sun: #2a2116; --moon: #1d1d2b; --chip: #2c2c2e; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 16px/1.55 -apple-system, "Segoe UI", Roboto, "Noto Sans Tamil", "Tamil Sangam MN", "Noto Sans Devanagari", "Noto Sans Telugu", "Noto Sans Kannada", "Noto Sans Malayalam", "Noto Sans Gujarati", "Noto Sans Bengali", sans-serif; }
a { color: var(--accent); }
/* On wide screens the header and the page stay centred instead of running to the window's edges;
   the header gets more room so its menus fit on one line */
:root { --page: 1160px; --header: 1440px; }
main { max-width: var(--page); margin: 0 auto; padding: 16px; }
h1 { font-size: 26px; margin: 8px 0 12px; }
h2 { font-size: 18px; color: var(--accent); margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 15px; font-weight: 400; }
.center { text-align: center; }
.accent { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Header */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 10px max(16px, calc((100% - var(--header)) / 2 + 16px));
          background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 18px; }
.brand img { width: 36px; height: 36px; border-radius: 9px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { text-decoration: none; color: var(--text); padding: 6px 12px; border-radius: 999px; }
nav a[aria-current] { background: var(--chip); font-weight: 600; }
.controls { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
/* The place and language pickers match the height and shape of the Vakya / Thirukanitham switch */
.controls select { height: 40px; border-radius: 999px; padding: 0 30px 0 14px; }
.controls form { margin: 0; }
select { font: inherit; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.lang, .segmented { display: inline-flex; background: var(--chip); border-radius: 999px; padding: 3px; }
.lang button, .segmented button { font: inherit; border: 0; background: none; color: var(--text); padding: 5px 14px; border-radius: 999px; cursor: pointer; }
.lang button[aria-pressed], .segmented button[aria-pressed] { background: var(--saffron); color: #fff; font-weight: 600; }
.segmented { margin-bottom: 12px; }

/* Cards */
.card { background: var(--card); border-radius: 18px; padding: 18px; margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } .controls { margin-left: 0; } }

.daynav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 12px; }
.daynav a, .monthhead a { font-size: 30px; text-decoration: none; padding: 0 12px; }
.daynav input { font: inherit; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); }

.hero { display: flex; justify-content: space-between; color: #fff; border-radius: 22px; padding: 20px 24px; margin-bottom: 14px;
        background: linear-gradient(120deg, var(--saffron), #cc381a); }
.hero .right { text-align: right; }
.weekday { font-size: 24px; font-weight: 700; }
.bignum { font-size: 72px; font-weight: 800; line-height: 1.05; }
.bignum.small { font-size: 48px; }
.tamonth { font-size: 30px; font-weight: 800; }
.chip { display: inline-block; margin-top: 6px; background: rgba(255,255,255,.22); padding: 3px 12px; border-radius: 999px; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--saffron); color: #fff;
          border-radius: 18px; padding: 14px 20px; margin-bottom: 14px; }
.banner-title { font-size: 20px; font-weight: 700; }
.pill { background: #fff; padding: 6px 16px; border-radius: 999px; font-weight: 700; }
.pill.good, td.good { color: var(--good); }
.pill.bad, td.bad { color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 400; color: var(--muted); vertical-align: top; padding: 8px 12px 8px 0; white-space: nowrap; }
td { padding: 8px 0; vertical-align: top; }
.spans tr + tr th, .spans tr + tr td, .avoid tr + tr th, .avoid tr + tr td { border-top: 1px solid var(--line); }
.avoid td { color: var(--bad); text-align: right; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { border-radius: 14px; padding: 10px 14px; }
.tile span { display: block; font-size: 13px; color: var(--muted); }
.tile b { font-size: 18px; }
.tile.sun { background: var(--sun); } .tile.moon { background: var(--moon); }
.festivals { margin: 0; padding-left: 20px; font-size: 18px; }

/* Hora */
.hora th { color: var(--muted); }
.hora td { padding: 9px 12px 9px 0; border-top: 1px solid var(--line); }
.hora tr.now td { background: color-mix(in srgb, var(--saffron) 18%, transparent); font-weight: 600; }
.hora tr.night td { opacity: .85; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.dot.g { background: var(--good); } .dot.b { background: var(--bad); }

/* Month */
.monthhead { display: flex; align-items: center; justify-content: space-between; text-align: center; }
.monthhead h1 { margin: 0; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 14px 0; }
.wd { text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.wd.sun { color: var(--accent); }
.cell { position: relative; display: flex; flex-direction: column; min-height: 76px; padding: 6px 8px; border-radius: 12px;
        background: var(--card); color: var(--text); text-decoration: none; }
.cell:hover { outline: 2px solid var(--saffron); }
.cell.today { background: color-mix(in srgb, var(--saffron) 20%, var(--card)); outline: 2px solid var(--accent); }
.cell .num { font-weight: 600; font-size: 18px; }
.cell .num.red { color: var(--accent); }
.cell .ta { margin-top: auto; text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.cell .ta.first { color: var(--accent); font-weight: 700; font-size: 11px; }
.cell .dot { position: absolute; top: 10px; right: 9px; }
.dot.new { background: var(--text); }
.dot.full { border: 2px solid #ff9500; background: none; }
.cell .bar { height: 3px; border-radius: 2px; background: var(--saffron); margin-top: 3px; }
.special td { border-top: 1px solid var(--line); padding: 8px 10px 8px 0; }
.special .n { font-weight: 700; width: 40px; } .special .r { text-align: right; }
@media (max-width: 520px) { .cell { min-height: 58px; padding: 4px 5px; } .cell .num { font-size: 15px; } .bignum { font-size: 56px; } }

.prose p { max-width: 65ch; }
code { background: var(--chip); padding: 1px 6px; border-radius: 6px; }
footer { text-align: center; color: var(--muted); padding: 24px 16px 40px; font-size: 14px; }

/* Cover: a Tamil tear-off daily sheet calendar (see templates/_tearoff.html) */
html.intro-playing body { overflow: hidden; }
.tearoff { position: fixed; inset: 0; z-index: 50; overflow-y: auto; outline: none; cursor: pointer;
           display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px 12px 32px;
           background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(6px); transition: opacity .5s ease; }
.tearoff[hidden] { display: none; }
.tearoff.done { opacity: 0; pointer-events: none; }
.tearoff.done .board { transform: translateY(-30px) scale(.94); }

/* The printed backing card the pad is stapled to */
.board { position: relative; width: min(440px, 94vw); margin-top: auto; padding: 14px 14px 22px; border-radius: 10px;
         background: linear-gradient(#cc381a 0 64px, transparent 64px), linear-gradient(120deg, #f58c21, #e2601f); box-shadow: 0 18px 40px rgba(0,0,0,.28);
         transition: transform .5s ease; animation: board-in .6s cubic-bezier(.2, .9, .3, 1.15) both; }
@keyframes board-in { from { transform: translateY(40px) scale(.94); opacity: 0; } }
.board-title { text-align: center; color: #fff; font-weight: 900; font-size: 24px; line-height: 1.2; }
.board-sub { text-align: center; color: #ffe2c7; font-weight: 700; font-size: 13px; letter-spacing: .04em; }

/* Wire hook through two holes, and the red binding fibres left by earlier sheets */
.hook { position: relative; height: 34px; margin-top: 18px; }
.hook i { position: absolute; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #7a2a0a;
          box-shadow: inset 0 2px 2px rgba(0,0,0,.6); }
.hook i:first-child { left: 18%; } .hook i:nth-child(2) { right: 18%; }
.hook .wire { position: absolute; left: calc(18% + 5px); right: calc(18% + 5px); top: 8px; height: 46px; z-index: 4;
              border: 2px solid #6d6d72; border-bottom: 0; border-radius: 40% 40% 0 0 / 70% 70% 0 0; }
.fibres { position: relative; z-index: 3; height: 12px; margin: -6px 4% -4px; background:
  repeating-linear-gradient(100deg, #b71c12 0 2px, transparent 2px 5px),
  repeating-linear-gradient(80deg, #fff 0 1px, transparent 1px 4px);
  -webkit-mask: linear-gradient(transparent, #000 40%, #000 60%, transparent); mask: linear-gradient(transparent, #000 40%, #000 60%, transparent); }

/* The sheet itself: newsprint, black ink, red for Sundays and festivals */
.dsheet { position: relative; z-index: 2; background: #fbfaf6; color: #151515; padding: 26px 10px 10px; text-align: center;
          box-shadow: 0 2px 0 #e6e1d4, 0 4px 0 #f3efe6, 0 6px 0 #dcd5c6, 0 8px 14px rgba(0,0,0,.18);
          font-family: "Tamil Sangam MN", "Noto Sans Tamil", -apple-system, sans-serif; transform-origin: 14% 0; }
.ds-date { font-family: "Arial Narrow", "Helvetica Neue", Arial, sans-serif; font-stretch: condensed; font-weight: 900;
           font-size: clamp(54px, 17vw, 84px); line-height: .95; letter-spacing: -1px; }
.dsheet.holiday .ds-date, .dsheet.holiday .ds-weekday { color: #d0201a; }
.ds-saying { font-size: 13px; margin: 6px 0 8px; font-weight: 600; }
.ds-row3 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr); border: 1.5px solid #222; }
.ds-box { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 4px 6px; }
.ds-box + .ds-box { border-left: 1.5px solid #222; }
.ds-small { text-align: left; font-size: 12px; font-weight: 700; line-height: 1.35; }
.ds-num { font-family: "Arial Narrow", Arial, sans-serif; font-weight: 900; font-size: 40px; line-height: 1; }
.ds-moon { font-size: 26px; }
.ds-box.mid { flex-direction: column; justify-content: center; padding: 0; }
.ds-band { align-self: stretch; background: #222; color: #fff; font-weight: 700; font-size: 15px; padding: 3px 0; }
.ds-weekday { font-weight: 800; font-size: 17px; padding: 3px 0; }
.ds-rasi { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1.5px solid #222; border-top: 0; font-size: 11.5px; }
.ds-rasi div { display: flex; justify-content: space-between; gap: 4px; padding: 2px 5px; border-right: 1px solid #bbb; }
.ds-rasi div:nth-child(4n) { border-right: 0; }
.ds-rasi b { font-weight: 600; } .ds-rasi .good b { font-weight: 800; }
/* Phones: the twelve rasis in 3 columns, so long names like விருச்சிகம் fit inside the box */
@media (max-width: 430px) {
  .ds-rasi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ds-rasi div:nth-child(4n) { border-right: 1px solid #bbb; }
  .ds-rasi div:nth-child(3n) { border-right: 0; }
  .ds-row3.bottom { font-size: 11px; }
  .ds-box.brand { font-size: 13px; }
}
.ds-text { text-align: left; font-size: 12.5px; line-height: 1.55; margin: 6px 2px; }
.ds-row3.bottom { font-size: 11.5px; }
.ds-row3.bottom .ds-box { flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 1px; text-align: left; }
.ds-head { font-weight: 800; border-bottom: 1px solid #999; margin-bottom: 2px; }
/* Bottom row: wider side boxes, and each line a label on the left with its value on the right, never split */
.ds-row3.bottom { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.3fr); }
.ds-kv { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; column-gap: 6px; }
/* When the box is too narrow the time moves under its label, still right-aligned and never split */
.ds-kv b { white-space: nowrap; font-weight: 700; margin-left: auto; }
.ds-head + .ds-kv, .ds-kv + .ds-head { margin-top: 2px; }
.ds-box.brand { align-items: center !important; text-align: center !important; font-weight: 800; color: #b5261e; gap: 3px !important; }
.ds-box.brand img { width: 34px; height: 34px; border-radius: 8px; }
.ds-sun { color: #333; font-weight: 600; font-size: 10.5px; }
.ds-place { font-size: 10.5px; color: #666; margin-top: 4px; }

/* Tearing: the sheet lifts off the wire at one corner and drops away */
.tearoff.tearing .dsheet.torn { animation: tear 1.1s cubic-bezier(.45, 0, .8, .4) forwards; }
@keyframes tear {
  0%   { transform: none; }
  15%  { transform: rotate(-2deg) translateY(-2px); }
  30%  { transform: rotate(7deg) translateY(4px); box-shadow: 8px 14px 24px rgba(0,0,0,.25); }
  45%  { transform: rotate(12deg) translate(10px, 18px); }
  100% { transform: rotate(40deg) translate(140px, 110vh); box-shadow: 18px 30px 40px rgba(0,0,0,.2); }
}
.tear-hint { margin-bottom: auto; color: var(--text); font-weight: 600; padding: 8px 18px; border-radius: 999px; background: var(--card);
             box-shadow: 0 2px 10px rgba(0,0,0,.12); animation: hint 1.6s ease-in-out .8s infinite; }
.tearoff.tearing .tear-hint { opacity: 0; transition: opacity .2s; }
@keyframes hint { 50% { transform: translateY(-5px); } }
@media (prefers-reduced-motion: reduce) { .board, .tear-hint { animation: none; } }

/* Which panchangam the page follows */
.lang.system button[aria-pressed] { background: var(--accent); }
.hero { position: relative; }
.system-badge { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,.95);
                color: #cc381a; font-weight: 700; font-size: 13px; padding: 3px 12px; border-radius: 999px; }
.saying { text-align: center; font-size: 18px; font-weight: 600; margin: 0 0 14px; }
.palan { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.palan div { display: flex; justify-content: space-between; gap: 6px; padding: 6px 10px; border-radius: 10px; background: var(--bg); }
.palan .good b { color: var(--good); } .palan .bad b { color: var(--bad); }
@media (max-width: 520px) { .palan { grid-template-columns: repeat(2, 1fr); } }

/* Years */
.years-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.year-cell { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center;
             padding: 8px 10px; border-radius: 12px; background: var(--bg); color: var(--text); text-decoration: none; }
.year-cell .yno { grid-row: span 2; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
                  background: var(--chip); font-size: 12px; font-weight: 700; }
.year-cell:hover { outline: 2px solid var(--saffron); }
.year-cell.current { background: color-mix(in srgb, var(--saffron) 22%, var(--card)); outline: 2px solid var(--accent); }
.year-hero { align-items: flex-end; }
.big2 { font-size: 30px; font-weight: 800; line-height: 1.2; }
.muted-white { opacity: .85; font-size: 14px; }
.monthhead span { width: 54px; }
.season { margin-top: 8px; font-size: 13px; opacity: .92; }
.ds-season { font-size: 11.5px; color: #555; margin: -4px 0 8px; }

/* Phones: place and language share a row (the place picker takes the spare width), the switch below */
@media (max-width: 760px) {
  .controls { width: 100%; }
  .controls form[data-testid="place-form"] { order: 1; flex: 1 1 0; min-width: 0; }
  .controls form[data-testid="place-form"] select { width: 100%; }
  .controls .langpick { order: 2; }
  .controls .langpick select { max-width: 130px; }
  .controls .system { order: 3; }
  nav a { padding-left: 9px; padding-right: 9px; }
}
