/* papertooth: planner pieces
   .pt-dayhead (today), .pt-week (seven days, from any first day), .pt-habits (tracker), .pt-dot-sticker */
.pt-dayhead { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 var(--pt-grid); padding-bottom: 12px; border-bottom: 2px solid var(--pt-ribbon); }
.pt-dayhead__num { font-family: var(--pt-font-type-head); font-size: 88px; line-height: 96px; color: var(--pt-ribbon); }
.pt-dayhead__meta { display: flex; flex-direction: column; padding-bottom: 12px; }
.pt-dayhead__month { font-family: var(--pt-font-type); font-size: 16px; line-height: 24px; letter-spacing: .12em; text-transform: uppercase; color: var(--pt-ribbon); }
.pt-dayhead__weekday { font-family: var(--pt-font-hand); font-size: 30px; line-height: 24px; color: var(--pt-pen); }
.pt-dayhead__kanji { --pt-stamp: var(--pt-stamp-vermilion); margin-bottom: 12px; width: 52px; height: 52px; font-size: 27px; }
.pt-dayhead__weekno { margin-left: auto; padding-bottom: 12px; font-family: var(--pt-font-type); font-size: 14px; line-height: 24px; opacity: .7; }

.pt-week-wrap { container-type: inline-size; }
.pt-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid color-mix(in srgb, var(--pt-ribbon) 45%, transparent); }
.pt-week__day { min-height: calc(var(--pt-grid) * 7); padding: 0 6px; border-right: 1px solid color-mix(in srgb, var(--pt-ribbon) 22%, transparent); display: flex; flex-direction: column; }
.pt-week__day:last-child { border-right: 0; }
.pt-week__head { display: flex; justify-content: space-between; align-items: baseline; height: 24px; font-family: var(--pt-font-type); font-size: 12px; line-height: 24px; color: var(--pt-ribbon); }
.pt-week__date { font-family: var(--pt-font-type-head); font-size: 17px; }
/* today's date, marked in red pencil (specific enough to win over marks.css in any load order; a style attribute still wins) */
.pt-week .pt-week__date.pt-anno { --pt-anno: var(--pt-ink-beni); --pt-ox: 6px; --pt-oy: 3px; }
.pt-week__head .pt-jp { font-size: 12px; }
/* Saturday in blue and Sunday in red, as on Japanese calendars. data-day (0 = Sunday … 6 = Saturday) places them
   wherever the week starts; without it, the week is taken to start on Monday. */
.pt-week__day:is([data-day="6"], :not([data-day]):nth-child(6)) .pt-week__head { color: var(--pt-pencil-blue); }
.pt-week__day:is([data-day="0"], :not([data-day]):nth-child(7)) .pt-week__head { color: var(--pt-pencil-red); }
.pt-week__day:is([data-day="0"], [data-day="6"], :not([data-day]):nth-child(n+6)) { background: color-mix(in srgb, var(--pt-ribbon) 2.5%, transparent); }
.pt-week__day p { font-family: var(--pt-font-hand); font-size: 20px; line-height: 24px; max-width: none; color: var(--pt-pen); }
.pt-dot-sticker { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 4px; background: #ffb3c7; box-shadow: inset 0 -1px 1px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.12); }

/* habit tracker: rows of <label class="pt-habit"><input type="checkbox"></label>; the script draws the circles */
.pt-habits-wrap { container-type: inline-size; }
/* wide: one row per habit, one column per day. The script places every cell, so narrow screens can swap rows and columns. */
.pt-habits { display: grid; grid-template-columns: minmax(96px, 168px) repeat(var(--pt-days, 14), 24px); grid-auto-rows: 24px; align-items: center; }
.pt-habits__row { --pt-hb: var(--pt-pen); display: contents; }
.pt-habits__row > * { grid-row: var(--pt-ra, auto); grid-column: var(--pt-ca, auto); }
.pt-habits__name { font-family: var(--pt-font-hand); font-size: 21px; line-height: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--pt-hb); }
.pt-habits__head > * { font-family: var(--pt-font-type); font-size: 11px; text-align: center; opacity: .6; color: var(--pt-ribbon); }
.pt-habits__head .pt-habits__name { font-size: 12px; text-align: left; text-transform: uppercase; letter-spacing: .08em; }
.pt-habit { display: grid; place-items: center; cursor: pointer; position: relative; height: 24px; }
/* a cell with content of its own (cell() in React): written in pen unless it brings its own ink */
.pt-habits__own { display: grid; place-items: center; height: 24px; color: var(--pt-pen); font: 400 20px/1 var(--pt-font-hand); }
.pt-habits__own .pt-stamp { --pt-pic-size: 18px; }
.pt-habit svg { overflow: visible; }
.pt-habit .pt-ring { fill: none; stroke: color-mix(in srgb, var(--pt-ribbon) 32%, transparent); stroke-width: 1; }
.pt-habit .pt-fill { fill: none; stroke: var(--pt-hb); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1 1; stroke-dashoffset: 1; transition: stroke-dashoffset .4s var(--pt-ease); }
.pt-habit input:checked ~ svg .pt-fill { stroke-dashoffset: 0; }
.pt-habit input:not(:checked) ~ svg .pt-fill { visibility: hidden; transition: stroke-dashoffset .4s var(--pt-ease), visibility 0s .4s; }
.pt-habit[data-pt-ready] input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pt-habit input:focus-visible ~ svg { outline: 2px dashed var(--pt-pen); outline-offset: 1px; }

/* narrow: the week becomes a list of days, and the tracker runs down the page, one row per day */
@container (max-width: 560px) {
  .pt-week { grid-template-columns: minmax(0, 1fr); }
  .pt-week__day { min-height: calc(var(--pt-grid) * 2); display: grid; grid-template-columns: 88px minmax(0, 1fr); column-gap: 12px; border-right: 0; border-bottom: 1px solid color-mix(in srgb, var(--pt-ribbon) 18%, transparent); }
  .pt-week__head { grid-row: 1 / span 3; gap: 8px; justify-content: flex-start; }
  .pt-week__day p { grid-column: 2; }
}
@container (max-width: 520px) {
  .pt-habits { grid-template-columns: 40px repeat(var(--pt-habit-count, 3), minmax(0, 1fr)); grid-auto-rows: auto; row-gap: 0; }
  .pt-habits__row > * { grid-row: var(--pt-rb, auto); grid-column: var(--pt-cb, auto); justify-self: center; }
  .pt-habits .pt-habit { height: 24px; }
  .pt-habits__name { white-space: normal; text-align: center; font-size: 17px; line-height: 18px; padding-bottom: 6px; align-self: end; }
  .pt-habits__head > :not(.pt-habits__name) { justify-self: start; }
}

/* date stamps: <div class="pt-datestamp" data-unit="week|month|year|day" data-variant="bar|wide" data-mark="circle" data-past="x"></div>.
   The script (or papertooth/react) fills it. Fine printed lines and small rounded labels, as on a stationery stamp,
   with cells to write in. It is printed twice from the same cells: .pt-datestamp__print in the stamp's ink and
   texture, and .pt-datestamp__marks laid exactly on top, carrying only the pencil marks (today circled, past crossed). */
.pt-datestamp {
  --pt-rot: 0deg; --pt-ds-col: 28px;
  position: relative; display: inline-block; vertical-align: middle; width: calc(7 * var(--pt-ds-col) + 3px);
  color: var(--pt-stamp, var(--pt-stamp-red));
  font-family: var(--pt-font-jp-round), var(--pt-font-type), sans-serif; font-weight: 700; font-size: 11px; line-height: 1;
  letter-spacing: .06em; text-transform: uppercase;
  transform: rotate(calc(var(--pt-rot) * var(--pt-tilt)));
}
.pt-datestamp:is([data-unit="month"], [data-unit="year"]) { --pt-ds-col: 34px; }
.pt-datestamp:is([data-variant="bar"], [data-unit="day"]) { width: max-content; }
/* a whole month in one row: a column naming the month, then a narrow column per day that shares out the width.
   Where there is not room for every day (a phone), the days keep a readable width and the stamp scrolls sideways;
   the two layers share one grid cell instead of the marks being laid over by position, so they scroll together. */
.pt-datestamp[data-unit="month"][data-variant="wide"] {
  display: inline-grid; grid-template-columns: minmax(max-content, 1fr);
  width: calc(46px + 31 * 22px); max-width: 100%;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
}
.pt-datestamp[data-variant="wide"] > * { grid-area: 1 / 1; }
.pt-datestamp[data-variant="wide"] > .pt-datestamp__marks { position: relative; inset: auto; }
.pt-datestamp[data-variant="wide"] .pt-datestamp__cell:not([data-side]) { min-width: 17px; }
.pt-datestamp:lang(ja) { letter-spacing: 0; }
.pt-datestamp__print { border: 1.5px solid currentColor; border-radius: 3px; filter: var(--pt-stamp-filter, ); opacity: var(--pt-stamp-opacity); mix-blend-mode: var(--pt-blend, multiply); }
.pt-datestamp__marks { position: absolute; inset: 0; border: 1.5px solid transparent; color: transparent; pointer-events: none; }
.pt-datestamp__section + .pt-datestamp__section, .pt-datestamp__row + .pt-datestamp__row { border-top: 1px solid currentColor; }
.pt-datestamp__row { display: flex; }
.pt-datestamp__cell { position: relative; flex: 1 1 0; min-width: 0; display: grid; place-items: center; height: 22px; }
.pt-datestamp__cell + .pt-datestamp__cell { border-left: 1px solid currentColor; }
/* the parts: a header of weekdays, cells to fill in, the months, the days of a month, a title line, a year of months, a bar */
[data-part="head"] .pt-datestamp__cell { height: 18px; font-size: 10px; }
[data-part="write"] .pt-datestamp__cell { height: 26px; }
[data-part="write"] .pt-datestamp__cell + .pt-datestamp__cell { border-left-style: dashed; }
[data-part="months"] .pt-datestamp__cell { height: 17px; font-size: 9px; }
:is([data-part="days"], [data-part="year"]) .pt-datestamp__cell { height: 28px; place-items: start; padding: 4px 4px 0; font-size: 10px; }
[data-part="year"] .pt-datestamp__cell { height: 34px; }
[data-part="title"] .pt-datestamp__cell { height: 24px; place-items: center start; padding: 0 6px; font-size: 12px; text-transform: none; }
.pt-datestamp[data-unit="year"] [data-part="title"] .pt-datestamp__cell { place-items: center; font-size: 13px; letter-spacing: .3em; }
.pt-datestamp[data-variant="wide"] .pt-datestamp__cell[data-side] { flex: 0 0 46px; font-size: 10px; letter-spacing: .03em; }
/* a week strip with row labels gets a first column for them, and grows by its width */
.pt-datestamp[data-unit="week"]:has(.pt-datestamp__cell[data-side]) { width: calc(7 * var(--pt-ds-col) + 3px + var(--pt-ds-side, 52px)); }
.pt-datestamp[data-unit="week"] .pt-datestamp__cell[data-side] { flex: 0 0 var(--pt-ds-side, 52px); font-size: 10px; letter-spacing: .03em; }
/* content placed in a cell (data-day, data-row, or cell() in React): written in pen unless it brings its own ink,
   centred on the cell, on top of the printed stamp */
.pt-datestamp__fill {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  color: var(--pt-pen); font: 400 1.5em/1 var(--pt-font-hand); letter-spacing: 0; text-transform: none;
}
.pt-datestamp__fill .pt-stamp { --pt-pic-size: min(80%, 18px); }
.pt-datestamp[data-variant="wide"] [data-part="days"] .pt-datestamp__cell { height: 22px; place-items: center; padding: 0; }
.pt-datestamp[data-variant="wide"] [data-part="write"] .pt-datestamp__cell { height: 24px; }
[data-part="bar"] .pt-datestamp__cell { flex: none; min-width: 28px; height: 26px; padding: 0 5px; font-size: 12px; }
/* the pencil marks (specific enough to win over marks.css in any load order) */
.pt-datestamp .pt-anno { white-space: normal; }
.pt-datestamp .pt-datestamp__label.pt-anno { --pt-ox: 7px; --pt-oy: 4px; }
.pt-datestamp__cell.pt-anno[data-anno="x"] { --pt-ox: -3px; --pt-oy: -3px; }
.pt-datestamp__cell.pt-anno[data-anno="strike"] { --pt-ox: -2px; --pt-oy: 0px; }
.pt-datestamp .pt-mark { padding: 1px .25em; }
