/* Pliego, on the guiles.es identity kit. Tokens come from guiles.css. */

:root {
	--p-header: 3.75rem;
	--p-status: 2rem;
	--p-nav: 15rem;
	--p-list: 26rem;
	--p-focus: 3px solid var(--g-mark);
}

html, body, .p-root { height: 100%; }
/* The page is the container, so the app's own grid can change with it. */
.p-root { container-type: inline-size; }
body {
	margin: 0;
	background: var(--g-paper);
	color: var(--g-ink);
	font-family: var(--g-sans);
	font-size: 1rem;
	line-height: 1.5;
}

/* Focus is always visible, and never colour alone: a thick ring. */
:focus-visible { outline: var(--p-focus); outline-offset: 2px; }

.p-visually-hidden {
	position: absolute !important; width: 1px; height: 1px; overflow: hidden;
	clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.p-skip {
	position: absolute; left: 0.5rem; top: -4rem; z-index: 20;
	background: var(--g-ink); color: var(--g-on-ink); padding: 0.6rem 1rem;
	text-decoration: none; font-weight: 600;
}
.p-skip:focus { top: 0.5rem; }
.p-loading { padding: 3rem var(--g-space); font-family: var(--g-serif); font-size: 1.5rem; }

.p-icon { width: 1.15em; height: 1.15em; fill: currentColor; flex: none; vertical-align: -0.18em; }

/* Buttons: ink for the main action, hairline for the rest. */
.p-button {
	display: inline-flex; align-items: center; gap: 0.5rem;
	min-height: 2.5rem; padding: 0.45rem 0.95rem;
	border: 1px solid var(--g-ink); border-radius: var(--g-radius);
	background: var(--g-paper); color: var(--g-ink);
	font: inherit; font-weight: 600; cursor: pointer;
}
.p-button:hover { background: var(--g-stone); }
.p-button.is-main { background: var(--g-ink); color: var(--g-on-ink); }
.p-button.is-main:hover { background: var(--g-ink-2); border-color: var(--g-ink-2); }
.p-button.is-quiet { border-color: transparent; }
.p-button.is-quiet:hover { border-color: var(--g-line); }
.p-button.is-danger { border-color: #b3261e; color: #b3261e; }
.p-button[disabled] { opacity: 0.55; cursor: not-allowed; }
.p-icon-button { min-width: 2.5rem; justify-content: center; padding: 0.45rem; }

/* Forms */
.p-field { display: grid; gap: 0.3rem; margin-bottom: 1rem; }
.p-field label { font-weight: 600; }
.p-field .p-hint { color: var(--g-ink-2); font-size: var(--g-small); margin: 0; }
.p-input, .p-select {
	min-height: 2.6rem; padding: 0.45rem 0.7rem;
	border: 1px solid var(--g-ink-2); border-radius: var(--g-radius);
	background: var(--g-paper); color: var(--g-ink); font: inherit;
}
.p-input:focus-visible, .p-select:focus-visible { outline: var(--p-focus); outline-offset: 0; }
.p-check { display: flex; gap: 0.6rem; align-items: flex-start; margin-bottom: 1rem; }
.p-check input { width: 1.2rem; height: 1.2rem; margin-top: 0.2rem; }
.p-error { border-left: 4px solid #b3261e; padding: 0.5rem 0.8rem; background: var(--g-stone); margin: 0 0 1rem; }
.p-note { border-left: 4px solid var(--g-mark); padding: 0.5rem 0.8rem; background: var(--g-stone); margin: 0 0 1rem; }

/* Sign in and join: a narrow page with the seal. */
.p-door {
	min-height: 100%; display: grid; place-items: start center;
	padding: 3rem var(--g-space);
}
.p-door-card { width: min(100%, 26rem); }
.p-door-brand { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1.5rem; }
.p-door-brand img { width: 3rem; height: 3rem; }
.p-door h1 { font-family: var(--g-serif); font-weight: 500; font-size: 2.4rem; margin: 0; line-height: 1.1; }
.p-door h2 { font-family: var(--g-serif); font-weight: 500; font-size: 1.6rem; margin: 0 0 1rem; }
.p-door-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-top: 1.25rem; }
.p-link { color: var(--g-link); background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.p-codes { columns: 2; font-family: var(--g-mono); font-size: 1.05rem; padding-left: 1.25rem; }
.p-qr { width: 14rem; height: 14rem; background: #fff; padding: 0.5rem; border: 1px solid var(--g-line); }

/* The app: header, three panes, a thin status line. */
.p-app {
	height: 100%;
	display: grid;
	grid-template-rows: var(--p-header) 1fr var(--p-status);
	grid-template-columns: var(--p-nav) var(--p-list) 1fr;
	grid-template-areas: "head head head" "nav list reader" "status status status";
}
.p-head {
	grid-area: head; display: flex; align-items: center; gap: 0.75rem;
	padding: 0 1rem; border-bottom: 1px solid var(--g-ink);
}
.p-brand { display: flex; align-items: center; gap: 0.55rem; color: var(--g-ink); text-decoration: none; margin-right: 0.5rem; }
.p-brand img { width: 2rem; height: 2rem; }
.p-brand span { font-family: var(--g-serif); font-size: 1.6rem; font-weight: 500; letter-spacing: 0.01em; }
.p-search { flex: 1; max-width: 34rem; display: flex; align-items: center; gap: 0.4rem; border: 1px solid var(--g-ink-2); border-radius: var(--g-radius); padding: 0 0.6rem; }
.p-search input { flex: 1; border: 0; background: transparent; color: inherit; font: inherit; min-height: 2.4rem; }
.p-search input:focus-visible { outline: none; }
.p-search:focus-within { outline: var(--p-focus); outline-offset: 1px; }
.p-head-end { margin-left: auto; display: flex; gap: 0.4rem; align-items: center; }

.p-nav { grid-area: nav; overflow: auto; border-right: 1px solid var(--g-line); padding: 0.75rem 0.5rem; }
.p-nav h2 { font-family: var(--g-serif); font-weight: 500; font-size: 1.15rem; margin: 1rem 0.5rem 0.35rem; }
.p-nav ul { list-style: none; margin: 0; padding: 0; }
.p-nav a {
	display: flex; align-items: center; gap: 0.6rem;
	padding: 0.45rem 0.6rem; color: var(--g-ink); text-decoration: none; border-radius: var(--g-radius);
	border-left: 3px solid transparent;
}
.p-nav a:hover { background: var(--g-stone); }
.p-nav a[aria-current="page"] { border-left-color: var(--g-mark); background: var(--g-stone); font-weight: 700; }
.p-count { margin-left: auto; font-weight: 700; font-size: var(--g-small); }
.p-account-state { font-size: var(--g-small); color: var(--g-ink-2); margin: 0 0.6rem 0.4rem; }

.p-list { grid-area: list; overflow: auto; border-right: 1px solid var(--g-line); }
.p-list-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--g-line); position: sticky; top: 0; background: var(--g-paper); z-index: 1; }
.p-list-head h1 { font-family: var(--g-serif); font-weight: 500; font-size: 1.45rem; margin: 0; }
.p-grid { display: block; }
.p-row {
	display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.75rem;
	padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--g-line); cursor: pointer;
	border-left: 4px solid transparent;
}
.p-row:hover { background: var(--g-stone); }
.p-row[aria-selected="true"] { background: var(--g-stone); border-left-color: var(--g-ink); }
.p-row:focus-visible { outline-offset: -3px; }
.p-row-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-row-date { color: var(--g-ink-2); font-size: var(--g-small); }
.p-row-subject { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-row-preview { grid-column: 1 / -1; color: var(--g-ink-2); font-size: var(--g-small); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Unread: heavier text AND a square mark, never colour alone. */
.p-row.is-unread .p-row-from, .p-row.is-unread .p-row-subject { font-weight: 800; }
.p-row.is-unread .p-row-from::before { content: ""; display: inline-block; width: 0.55rem; height: 0.55rem; background: var(--g-mark); margin-right: 0.45rem; vertical-align: 0.1rem; }
.p-row-marks { display: inline-flex; gap: 0.3rem; color: var(--g-ink-2); }
.p-empty { padding: 2rem 1rem; color: var(--g-ink-2); }
.p-more { display: block; margin: 1rem auto; }

.p-reader { grid-area: reader; overflow: auto; }
.p-reader-empty { padding: 3rem 2rem; color: var(--g-ink-2); font-family: var(--g-serif); font-size: 1.3rem; }
.p-message { padding: 1.25rem 1.5rem 2rem; max-width: 60rem; }
.p-message h1 { font-family: var(--g-serif); font-weight: 500; font-size: 1.9rem; line-height: 1.2; margin: 0 0 0.75rem; }
.p-toolbar { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.p-people { margin: 0 0 1rem; display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.75rem; }
.p-people dt { color: var(--g-ink-2); }
.p-people dd { margin: 0; overflow-wrap: anywhere; }
.p-warning { border-left: 4px solid #b3261e; background: var(--g-stone); padding: 0.6rem 0.9rem; margin: 0 0 0.75rem; display: flex; gap: 0.6rem; }
.p-frame { width: 100%; min-height: 12rem; border: 1px solid var(--g-line); background: #fff; display: block; }
.p-attachments { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.p-attachments a { display: inline-flex; gap: 0.4rem; align-items: center; border: 1px solid var(--g-line); padding: 0.4rem 0.7rem; color: var(--g-ink); text-decoration: none; }

.p-status {
	grid-area: status; display: flex; align-items: center; gap: 1rem;
	padding: 0 1rem; border-top: 1px solid var(--g-ink); font-size: var(--g-small); color: var(--g-ink-2);
}
.p-status img { width: 1.2rem; height: 1.2rem; }
.p-status strong { color: var(--g-ink); font-weight: 600; }

/* Dialogs */
.p-dialog { border: 1px solid var(--g-ink); border-radius: var(--g-radius); padding: 0; width: min(46rem, calc(100% - 2rem)); background: var(--g-paper); color: var(--g-ink); }
.p-dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.p-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; border-bottom: 1px solid var(--g-line); }
.p-dialog-head h2 { font-family: var(--g-serif); font-weight: 500; margin: 0; font-size: 1.5rem; }
.p-dialog-body { padding: 1rem; max-height: 75vh; overflow: auto; }
.p-dialog-foot { display: flex; gap: 0.5rem; justify-content: flex-end; padding: 0.75rem 1rem; border-top: 1px solid var(--g-line); flex-wrap: wrap; }

/* Compose */
.p-compose-grid { display: grid; grid-template-columns: 5rem 1fr; gap: 0.5rem 0.75rem; align-items: center; margin-bottom: 0.75rem; }
.p-compose-grid label { font-weight: 600; }
.p-editor-bar { display: flex; flex-wrap: wrap; gap: 0.2rem; border: 1px solid var(--g-ink-2); border-bottom: 0; padding: 0.25rem; }
.p-editor { min-height: 14rem; border: 1px solid var(--g-ink-2); padding: 0.75rem; overflow-wrap: anywhere; }
.p-editor:focus-visible { outline: var(--p-focus); outline-offset: 0; }
.p-editor blockquote { border-left: 3px solid var(--g-line); margin: 0.5rem 0; padding-left: 0.75rem; color: var(--g-ink-2); }
.p-emoji { border: 1px solid var(--g-line); padding: 0.5rem; margin-top: 0.5rem; }
.p-emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); max-height: 12rem; overflow: auto; }
.p-emoji-grid button { font-size: 1.4rem; background: none; border: 1px solid transparent; min-height: 2.6rem; cursor: pointer; }
.p-emoji-grid button:hover, .p-emoji-grid button:focus-visible { border-color: var(--g-ink); }
.p-keys { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; }
.p-keys kbd { font-family: var(--g-mono); border: 1px solid var(--g-ink-2); padding: 0 0.4rem; border-radius: var(--g-radius); }
.p-table { width: 100%; border-collapse: collapse; }
.p-table th, .p-table td { text-align: left; padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--g-line); vertical-align: top; }

/* Narrower: two panes, then one. Done in CSS, so zoom works the same. */
@container (max-width: 72rem) {
	.p-app { grid-template-columns: var(--p-list) 1fr; grid-template-areas: "head head" "list reader" "status status"; }
	.p-nav { display: none; }
	.p-app.is-nav-open .p-nav { display: block; position: fixed; inset: var(--p-header) auto var(--p-status) 0; width: var(--p-nav); background: var(--g-paper); z-index: 5; border-right: 1px solid var(--g-ink); }
}
@container (max-width: 46rem) {
	.p-app { grid-template-columns: 1fr; grid-template-areas: "head" "list" "status"; }
	.p-reader { display: none; }
	.p-app.is-reading .p-reader { display: block; grid-area: list; }
	.p-app.is-reading .p-list { display: none; }
	.p-brand span, .p-head .p-label { display: none; }
}
.p-only-narrow, .p-only-phone { display: none; }
@container (max-width: 72rem) { .p-only-narrow { display: inline-flex; } }
@container (max-width: 46rem) { .p-only-phone { display: inline-flex; } }

@media (pointer: coarse) {
	.p-row { padding-block: 0.9rem; }
	.p-nav a { padding-block: 0.7rem; }
}
@media (prefers-reduced-motion: reduce) {
	* { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
	.p-row[aria-selected="true"], .p-nav a[aria-current="page"] { outline: 2px solid Highlight; }
	.p-row.is-unread .p-row-from::before { background: CanvasText; }
}
.p-or { margin: 1rem 0 1.25rem; }
