/*
 * LittleNoted: a note sent by hand. White paper, one serif, blue-black ink,
 * hairline rules, one flourish.
 *
 * The share page must work on old phones (tested on iOS 12), so no flex `gap`,
 * clamp(), :is()/:where(), aspect-ratio or inset here. Grid `gap` is fine.
 */

:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #1f1e1c;
  --ink-blue: #263f66;   /* links, claims: fountain-pen ink */
  --faded: #6e6a63;      /* meta, placeholders */
  --rule: #cfcac1;       /* hairlines */
  --rule-soft: #e7e3dc;
  --alert: #9b2c2c;
  --serif: "Libre Caslon Text", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }

html { background: var(--paper); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 1rem;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.65 var(--serif);
}

/* The note card: a thin double rule, like engraved stationery. */
/* One width on every page, so the frame doesn't jump between pages. */
.note {
  max-width: 60rem;
  margin: 1rem auto 0;
  padding: 1.75rem 1.25rem 2.5rem;
  border: 1px solid var(--rule);
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 5px var(--rule);
}
@media (min-width: 40rem) {
  body { padding: 2rem; }
  .note { padding: 2.5rem 3rem 3rem; }
}

/* Header: the script logo centred, the nav as a quiet italic line under it. */
header { text-align: center; padding-bottom: 1.25rem; margin-bottom: 2rem; border-bottom: 1px solid var(--rule-soft); }
.brand { display: inline-block; }
.brand img { display: block; width: 13rem; max-width: 100%; height: auto; margin: 0 auto; }
nav { margin-top: .75rem; font-style: italic; font-size: .9375rem; }
nav a, nav .link { display: inline-block; margin: 0 .5rem; }

a { color: var(--ink-blue); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--ink); }

h1, h2, h3 { font-weight: 400; line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 2rem; letter-spacing: .01em; }
h2 { font-size: 1.375rem; margin-top: 2rem; }
h3 { font-size: 1.125rem; }
p { margin: 0 0 1rem; }

.meta { color: var(--faded); font-style: italic; margin: 0; }
.alert { color: var(--alert); margin-bottom: 1rem; }
.notice { color: var(--ink-blue); font-style: italic; margin-bottom: 1rem; }

/* The flourish: a hairline with a small knot at its centre. */
hr { border: 0; border-top: 1px solid var(--rule-soft); margin: 2rem 0; }
hr.flourish {
  border: 0;
  height: 16px;
  margin: 1.5rem auto;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='16' viewBox='0 0 160 16'%3E%3Cg fill='none' stroke='%23263f66' stroke-width='1' stroke-linecap='round'%3E%3Cpath d='M20 8H64C70 8 72 3 76 3S80 8 80 8 80 13 84 13 90 8 96 8H140'/%3E%3Cpath d='M64 8C70 8 72 13 76 13S80 8 80 8 80 3 84 3 90 8 96 8'/%3E%3C/g%3E%3C/svg%3E") center no-repeat;
}

.page-head { text-align: center; }
.page-head .meta { font-size: 1.0625rem; }

/* Forms: words written on a line. */
form:not(.inline) { display: grid; gap: .6rem; max-width: 24rem; margin-bottom: 1rem; }
form.inline, .inline { display: inline; }

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=date], input:not([type]), select, textarea {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  padding: .35rem .1rem;
  width: 100%;
  -webkit-appearance: none;
}
textarea { border: 1px solid var(--rule); padding: .5rem; min-height: 6rem; }
select { -webkit-appearance: menulist; }
input::placeholder, textarea::placeholder { color: var(--faded); font-style: italic; opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--ink-blue); }
/* Underlined fields show focus as a heavier ink line rather than a box. */
input:not([type=submit]):focus-visible { outline: none; box-shadow: 0 1px 0 var(--ink-blue); }
input[readonly] { color: var(--faded); }

button, input[type=submit] {
  font: inherit;
  font-size: .9375rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: .45rem 1.1rem;
  cursor: pointer;
  -webkit-appearance: none;
}
button:hover, input[type=submit]:hover { background: var(--ink); color: var(--paper); }
form:not(.inline) > input[type=submit], form:not(.inline) > button { justify-self: start; }
.meta + form { margin-top: 1rem; }

/* Secondary actions read as links, not buttons. */
button.link, form.inline button {
  border: 0; padding: 0; background: none;
  color: var(--ink-blue); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em;
}
button.link:hover, form.inline button:hover { background: none; color: var(--ink); }
nav .link { font-style: italic; font-size: .9375rem; }
/* Space between side-by-side actions: Edit / Remove, Replace link / Stop sharing. */
a + form.inline, form.inline + form.inline { margin-left: .9rem; }
nav form.inline { margin-left: 0; }

:focus-visible { outline: 2px solid var(--ink-blue); outline-offset: 3px; }

/* Running text keeps a readable line length inside the wide note. */
main > p, main > ul, main > ol, .page-head p { max-width: 42rem; }
.page-head p { margin-left: auto; margin-right: auto; }

.icon { display: inline-block; vertical-align: middle; }
.empty { text-align: center; color: var(--faded); font-style: italic; padding: 2rem 0; }
.empty .icon { color: var(--rule); margin-bottom: .5rem; }

/* Cards: each item (or list) is its own small framed note. Two across on a
   phone, three on a wide screen. Grid, not flex gap: iOS 12 runs the share page. */
.cards { display: grid; grid-template-columns: 1fr 1fr; grid-gap: .75rem; gap: .75rem; }
@media (min-width: 48rem) { .cards { grid-template-columns: 1fr 1fr 1fr; grid-gap: 1.25rem; gap: 1.25rem; } }

/* A column, so the actions and claim form sit at the foot of every card in a row. */
.item { display: -webkit-box; display: flex; -webkit-box-orient: vertical; flex-direction: column; padding: .5rem .5rem .75rem; border: 1px solid var(--rule); background: var(--paper); min-width: 0; }
.item-image { display: block; position: relative; padding-top: 100%; margin-bottom: .6rem; background: #faf9f6; }
.item-image img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; }
.item-image .icon { position: absolute; top: 50%; left: 50%; margin: -16px 0 0 -16px; color: var(--rule); }
.item-body { -webkit-box-flex: 1; flex: 1; display: -webkit-box; display: flex; -webkit-box-orient: vertical; flex-direction: column; padding: 0 .25rem; overflow-wrap: break-word; }
.item h3 { font-size: 1rem; line-height: 1.35; margin: 0 0 .2rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.item h3 a { color: var(--ink); text-decoration: none; }
.item h3 a:hover { color: var(--ink-blue); text-decoration: underline; }
.item .meta { font-size: .875rem; margin-bottom: .3rem; }
.item .notes { font-size: .875rem; margin: 0 0 .3rem; }
.item-actions { margin-top: auto; padding-top: .4rem; text-align: right; }
.item-actions a + form.inline { margin-left: .1rem; }

a.list-card { color: var(--ink); text-decoration: none; }
a.list-card:hover { border-color: var(--ink); }
a.list-card .icon { vertical-align: -2px; }
.new-card { border-style: dashed; display: -webkit-box; display: flex; align-items: center; justify-content: center; min-height: 12rem; }

/* Thin icon-only buttons (edit, remove, close): faded until hovered. */
.icon-button, form.inline button.icon-button {
  display: inline-block; padding: .35rem; border: 0; background: none; line-height: 0;
  color: var(--faded); text-decoration: none; cursor: pointer;
}
.icon-button:hover, form.inline button.icon-button:hover { color: var(--ink); background: none; }

/* Action tiles: a framed icon with its word under it. Each opens a modal. */
.actions { display: flex; justify-content: center; margin-top: 1.5rem; }
/* Up to 4.75rem each, shrinking so four fit across a phone; labels wrap under their icon. */
.action { flex: 0 1 4.75rem; min-width: 0; text-align: center; }
/* form.inline button.tile: archive and restore are buttons in a form, not links. */
.tile, form.inline button.tile {
  display: inline-block; text-align: center; background: none; border: 0; padding: 0; text-decoration: none;
  color: var(--ink); font-size: .8125rem; font-style: italic;
}
.tile .icon, form.inline button.tile .icon { display: block; box-sizing: content-box; padding: .65rem; margin: 0 auto .35rem; border: 1px solid var(--ink); background: var(--paper); }
.tile:hover, form.inline button.tile:hover { background: none; color: var(--ink); }
.tile:hover .icon { background: var(--ink); color: var(--paper); }

/* Modals: the note's double rule, lifted off a dimmed page. */
dialog {
  width: calc(100% - 2rem); max-width: 27rem; padding: 0;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule);
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 5px var(--rule), 0 16px 48px rgba(31, 30, 28, .2);
}
dialog::backdrop { background: rgba(31, 30, 28, .35); }
.dialog-body { padding: 1.25rem 1.25rem 1.5rem; text-align: left; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.dialog-head h2 { margin: 0; font-size: 1.375rem; }
.dialog-body form:not(.inline) { max-width: none; }
.dialog-body p { margin-bottom: .9rem; }
.or { text-align: center; font-style: italic; color: var(--faded); margin: .5rem 0; }

/* A read-only value with a Copy button beside it. */
.copy-field { display: grid; gap: .6rem; margin-bottom: 1rem; }
.copy-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: end; }
.copy-row button .icon { vertical-align: -3px; }

a.tile { text-decoration: none; }

/* Panels: one framed box per purpose (Occasions, Gift ideas, Your name...). */
.panel { border: 1px solid var(--rule); padding: 1.25rem 1.25rem 1.4rem; margin: 0 0 1.25rem; }
.panel > h2, .panel-head h2 { font-size: 1.125rem; margin: 0 0 .9rem; }
.panel > h2 .icon { vertical-align: -3px; margin-right: .2rem; }
.panel > :last-child { margin-bottom: 0; }
.panel form:not(.inline) { max-width: 28rem; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; }
.panel-head h2 .meta, .rows .meta { font-size: .875rem; margin-left: .3rem; }

/* Rows: a hairline-ruled list with its actions on the right. */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; align-items: center; padding: .55rem 0; border-top: 1px solid var(--rule-soft); }
.rows li:first-child { border-top: 0; padding-top: 0; }
.rows li:last-child { padding-bottom: 0; }
.rows li.bought > span:first-child { color: var(--faded); text-decoration: line-through; }

.steps { margin: 0; padding-left: 1.25rem; }
.steps li { margin-bottom: .5rem; }

/* What you know about a person: labels beside values on a wide screen. */
.profile { margin: 0; }
.profile dt { font-weight: 400; font-style: italic; color: var(--faded); font-size: .9375rem; }
.profile dd { margin: 0 0 .75rem; }
.profile dd p { margin: 0; }
@media (min-width: 40rem) {
  .profile { display: grid; grid-template-columns: 7rem 1fr; gap: 0 1.25rem; }
  .profile dt { padding-top: .1rem; }
}

/* People as cards: an italic initial in a thin circle, like a wax seal drawn in ink. */
a.person-card { color: var(--ink); text-decoration: none; text-align: center; padding: 1.25rem .75rem 1rem; }
a.person-card:hover { border-color: var(--ink); }
.monogram {
  display: block; width: 3.5rem; height: 3.5rem; line-height: 3.4rem; margin: 0 auto .75rem;
  border: 1px solid var(--ink-blue); border-radius: 50%;
  color: var(--ink-blue); font-style: italic; font-size: 1.375rem;
}
.person-card .meta { font-size: .875rem; }

.back { display: inline-block; margin-top: .5rem; font-style: italic; font-size: .9375rem; }
.back .icon { vertical-align: -2px; }
label.check { margin: 0; font-style: normal; color: var(--ink); font-size: .9375rem; }
p.danger form.inline button { color: var(--alert); }
.suggestion form.inline button { margin: .25rem .75rem 0 0; }
.suggestion form.inline button .icon { vertical-align: -2px; }

/* The item form keeps a small framed photo. */
.thumb { width: 6rem; height: 6rem; padding: 3px; object-fit: contain; background: var(--paper); border: 1px solid var(--rule); }

.claim { margin: .25rem 0; color: var(--ink-blue); font-style: italic; font-size: .875rem; }

/* Claiming: name, then the button, under the item. */
.claim-form { display: grid; gap: .5rem; margin: auto 0 0; padding-top: .6rem; }
.claim-form input[type=number] { width: 5rem; }
.claim-form input[type=submit] { justify-self: start; }
.link-person { display: grid; grid-template-columns: 1fr auto; gap: .5rem; max-width: 28rem; margin: 0 0 1rem; }
.link-person label { grid-column: 1 / -1; margin: 0; }

dt { font-weight: 700; }
dd { margin: 0 0 .75rem; }

footer { max-width: 42rem; margin: 1.5rem auto 2rem; text-align: center; font-size: .875rem; font-style: italic; }
footer a { color: var(--faded); }

label { font-size: .875rem; font-style: italic; line-height: 1.3; color: var(--faded); margin: .25rem 0 -.5rem; }

/* Archived lists: folded away under the live ones. */
details.archived { margin-top: 1.5rem; }
details.archived summary { cursor: pointer; font-style: italic; color: var(--faded); margin-bottom: 1rem; }
details.archived summary .icon { vertical-align: -3px; margin-right: .2rem; }
details.archived .item-image img { opacity: .7; }
.notice .icon { vertical-align: -3px; }

.pager { text-align: center; margin-top: 1.5rem; }
.pager a { margin: 0 .75rem; }

/* Home page: a few screenshots framed like the item cards. */
.home-cta { margin-top: 1.25rem; }
.home-cta a + a { margin-left: 1rem; }
.cta-button { display: inline-block; padding: .5rem 1.4rem; border: 1px solid var(--ink); color: var(--ink); text-decoration: none; }
.cta-button:hover { background: var(--ink); color: var(--paper); }
.home-step { margin-bottom: 2.5rem; }
.home-step img { display: block; width: 100%; height: auto; margin: 1rem 0 .5rem; border: 1px solid var(--rule); }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.rows.stores li { flex-wrap: wrap; gap: .4rem .75rem; }
.rows.stores input[type=text] { width: 13rem; max-width: 100%; margin-right: .4rem; }
.affiliate-note { display: block; margin-top: .3rem; }
