/* iainMail
   Reading-first mail. One column, one thing at a time.

   The rules behind the look:
   - Never pure white on pure black. Bright text on true black smears at the
     edges (halation), which is tiring for everyone and worse for some. Warm
     off-white on a warm near-black instead.
   - Line length is capped. Long lines lose your place on the return sweep.
   - Space is structure. Gaps do the work that borders and boxes usually do.
   - Emphasis is weight and colour, never italics.
*/

@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&display=swap');

:root {
  --bg:          #16181c;
  --surface:     #1d2127;
  --surface-up:  #242931;
  --line:        #2d333c;

  --text:        #e6e2dc;
  --text-dim:    #9aa2ac;

  --people:        #7fb0d4;
  --bills:         #dda45e;
  --newsletters:   #a2bd8e;
  --notifications: #ad9fcb;
  --spam:          #c98d8d;
  --accent:        var(--people);

  --measure: 80ch;
  --radius: 14px;

  --gap-s:  0.75rem;
  --gap-m:  1.5rem;
  --gap-l:  2.5rem;
  --gap-xl: 4rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Atkinson Hyperlegible', system-ui, -apple-system, sans-serif;
  font-size: 19px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  word-spacing: 0.04em;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--text); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap {
  width: 94%;
  max-width: 100rem;
  margin: 0 auto;
  padding: var(--gap-l) 0 var(--gap-xl);
}

/* ---------- top bar ---------- */

.bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--gap-m);
  margin-bottom: var(--gap-l);
}
.bar .brand { margin-right: auto; }

.brand {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}
.brand span { color: var(--text-dim); font-weight: 400; }

/* ---------- piles ---------- */

.piles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-s);
  margin-bottom: var(--gap-l);
  padding: 0;
  list-style: none;
}

.pile {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.1rem;
  min-height: 3rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.95rem;
}

.pile:hover { background: var(--surface); color: var(--text); }

.pile[aria-current="page"] {
  background: var(--surface-up);
  border-color: transparent;
  color: var(--text);
  font-weight: 700;
}

.pile .count {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 400;
}
.pile[aria-current="page"] .count { color: var(--text-dim); }

.dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

/* colour by pile */
.c-people        { --accent: var(--people); }
.c-bills         { --accent: var(--bills); }
.c-newsletters   { --accent: var(--newsletters); }
.c-notifications { --accent: var(--notifications); }
.c-spam          { --accent: var(--spam); }

/* ---------- the list ---------- */

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 var(--gap-m);
  letter-spacing: -0.01em;
}

.list { list-style: none; margin: 0; padding: 0; }

.item { margin-bottom: var(--gap-s); }

.card {
  display: block;
  padding: 1.25rem 1.5rem 1.25rem 1.35rem;
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease, transform 0.15s ease;
}

.card:hover { background: var(--surface-up); transform: translateX(2px); }

.card .who {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--gap-m);
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.card .name { color: var(--text); }
.card.unread .name { font-weight: 700; }

.card .subject {
  font-size: 1.05rem;
  margin: 0 0 0.4rem;
  line-height: 1.45;
}
.card.unread .subject { font-weight: 700; }

.card .snippet {
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.6;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- reading a message ---------- */

.back {
  display: inline-block;
  margin-bottom: var(--gap-m);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.95rem;
}
.back:hover { color: var(--text); }

.head { margin-bottom: var(--gap-l); }

.head h1 {
  font-size: 1.75rem;
  line-height: 1.35;
  margin-bottom: var(--gap-s);
}

.meta {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.6;
}
.meta .from { color: var(--text); }
.meta .addr { font-size: 0.85rem; }

/* the one flourish: say out loud why this landed where it did */
.why {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: var(--gap-m);
  padding: 0.6rem 1rem 0.6rem 0.85rem;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.why strong { color: var(--text); font-weight: 700; }

.body {
  max-width: var(--measure);
  margin-top: var(--gap-l);
  padding-top: var(--gap-l);
  border-top: 1px solid var(--line);
  font-size: 1.05rem;
  line-height: 1.85;
  overflow-wrap: break-word;
}

.body p { margin: 0 0 1.4em; }
.body h1, .body h2, .body h3, .body h4 {
  font-size: 1.15rem;
  margin: 2em 0 0.6em;
  line-height: 1.4;
}
.body ul, .body ol { padding-left: 1.4em; margin: 0 0 1.4em; }
.body li { margin-bottom: 0.6em; }
.body blockquote {
  margin: 0 0 1.4em;
  padding-left: 1.2em;
  border-left: 3px solid var(--line);
  color: var(--text-dim);
}
.body pre {
  background: var(--surface);
  padding: 1rem 1.25rem;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
}
.body em, .body i { font-style: normal; font-weight: 700; }
.body hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.muted { color: var(--text-dim); }

/* ---------- actions ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-s);
  margin-top: var(--gap-xl);
  padding-top: var(--gap-l);
  border-top: 1px solid var(--line);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.7rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { background: var(--surface-up); }
.btn-primary { background: var(--surface-up); border-color: transparent; font-weight: 700; }
.btn-quiet { color: var(--text-dim); border-color: transparent; }
.btn-quiet:hover { color: var(--text); }

.file {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-s);
  margin-top: var(--gap-m);
  color: var(--text-dim);
  font-size: 0.9rem;
}

select {
  font: inherit;
  font-size: 0.95rem;
  min-height: 3rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* ---------- empty ---------- */

.empty {
  padding: var(--gap-xl) 0;
  color: var(--text-dim);
  max-width: var(--measure);
}
.empty p { margin: 0 0 1rem; }

/* ---------- responsive & motion ---------- */

@media (max-width: 34rem) {
  body { font-size: 18px; }
  .wrap { padding: var(--gap-m) 1rem var(--gap-xl); }
  .head h1 { font-size: 1.4rem; }
  .card { padding: 1.1rem 1.1rem 1.1rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .card:hover { transform: none; }
}

/* ---------- sign in ---------- */

.gate { max-width: 26rem; padding-top: var(--gap-xl); }
.gate .brand { display: block; margin-bottom: var(--gap-l); }
.gate h1 { margin-bottom: 0.4rem; }
.gate .muted { margin: 0 0 var(--gap-l); }

.signin { display: flex; flex-direction: column; gap: 0.5rem; }

.signin label {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-top: var(--gap-m);
}

.signin input {
  font: inherit;
  font-size: 1.05rem;
  min-height: 3.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.signin input:focus { border-color: var(--accent); }

.signin button { margin-top: var(--gap-l); justify-content: center; }

.error {
  padding: 0.85rem 1.1rem;
  margin-bottom: var(--gap-m);
  background: var(--surface);
  border-left: 3px solid var(--spam);
  border-radius: 0 10px 10px 0;
  font-size: 0.95rem;
}

.bar-actions { display: flex; gap: var(--gap-s); flex-wrap: wrap; }


/* ---------- search ---------- */

.search {
  display: flex;
  gap: var(--gap-s);
  flex: 1 1 22rem;
  max-width: 40rem;
}

.search input {
  flex: 1;
  font: inherit;
  font-size: 1rem;
  min-height: 3rem;
  padding: 0.6rem 1.1rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.search input:focus { border-color: var(--accent); }
.search input::placeholder { color: var(--text-dim); }

/* ---------- list rows with actions ---------- */

.row {
  display: flex;
  align-items: stretch;
  gap: var(--gap-s);
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  overflow: hidden;
  transition: background 0.15s ease;
}

.row:hover { background: var(--surface-up); }

.row .card {
  flex: 1;
  min-width: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
}
.row .card:hover { background: transparent; transform: none; }

.row-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.9rem 1rem 0.9rem 0;
  flex: none;
}

.row-actions .btn {
  min-height: 2.4rem;
  padding: 0.35rem 1rem;
  font-size: 0.85rem;
}

.danger { color: var(--spam); }
.danger:hover { background: var(--surface); color: var(--spam); }

/* ---------- attachments ---------- */

.files { margin-bottom: var(--gap-l); }
.files h2 {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-dim);
  margin: 0 0 var(--gap-s);
}
.files ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--gap-s); }

.file-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.8rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
}
.file-chip:hover { background: var(--surface-up); border-color: var(--accent); }
.file-name { font-size: 0.95rem; }
.file-size { font-size: 0.8rem; color: var(--text-dim); }

/* ---------- held-back images ---------- */

.notice {
  max-width: var(--measure);
  padding: 0.85rem 1.2rem;
  margin: 0 0 var(--gap-m);
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* pictures inside a message */

.body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0.5em 0;
}

@media (max-width: 48rem) {
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .row { flex-direction: column; }
  .row-actions {
    flex-direction: row;
    justify-content: flex-end;
    padding: 0 1.1rem 0.9rem;
  }
}
