/* pilucho.css | MIT License */
/* A classless CSS framework for semantic HTML */
/* https://github.com/claudioruiz/pilucho.css */

/* ==========================================
   1. Custom Properties
   ========================================== */

:root {
  /* Typography */
  --font-sans:
    -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Ubuntu,
    Roboto, Noto, "Segoe UI", Arial, sans-serif;
  --font-mono:
    "SF Mono", Monaco, Inconsolata, "Roboto Mono", Consolas, monospace;
  --font-heading:
    "Helvetica Neue", Helvetica, -apple-system, BlinkMacSystemFont, "Segoe UI",
    system-ui, sans-serif;

  /* Colors */
  --bg: #fff;
  --accent-bg: #f5f7ff;
  --text: #212121;
  --text-light: #585858;
  --border: #898ea4;
  --accent: #212121;
  --accent-hover: #dd3131;
  --accent-text: var(--bg);
  --code: #d81b60;
  --preformatted: #444;
  --marked: #ffdd33;
  --disabled: #efefef;

  /* Layout */
  --content-width: min(45rem, 90%);

  /* Misc */
  --border-radius: 5px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --accent-bg: #1e2235;
    --text: #e0e0e0;
    --text-light: #a0a0a0;
    --border: #3a3f56;
    --accent: #e0e0e0;
    --accent-hover: #ff6b6b;
    --code: #ff79c6;
    --preformatted: #ccc;
    --disabled: #2a2a2a;
  }
}

/* ==========================================
   2. Reset
   ========================================== */

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

textarea,
select,
input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"])),
progress {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

::selection {
  background: var(--accent);
  color: var(--accent-text);
}

:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}

/* ==========================================
   3. Base / Layout
   ========================================== */

html {
  font-family: var(--font-sans);
  scroll-behavior: smooth;
}

body {
  color: var(--text);
  background-color: var(--bg);
  font-size: 1.15rem;
  line-height: 1.5;
  display: grid;
  grid-template-columns: 1fr var(--content-width) 1fr;
  min-height: 100vh;
  margin: 0;
}

body > * {
  grid-column: 2;
}

body > header {
  grid-column: 2;
  padding: 2rem 0 3rem 0;
}

body > footer {
  grid-column: 1 / -1;
  padding: 2rem;
  margin-top: 3rem;
  font-size: 0.9rem;
  color: var(--text-light);
  text-align: center;
  border-top: 1px solid var(--border);
}

main {
  grid-column: 2;
  padding: 1.5rem 0;
  width: 100%;
}

/* ==========================================
   4. Typography
   ========================================== */

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

p {
  margin: 1.5rem 0;
  font-size: 1.15rem;
  line-height: 1.6;
  letter-spacing: 0.01em;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
  scroll-margin-top: 2rem;
}

h1 {
  font-size: 2.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

h2 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-top: 3rem;
  margin-bottom: 1.25rem;
}

h3 {
  font-size: 1.375rem;
  font-weight: 600;
  margin-top: 3rem;
  margin-bottom: 1rem;
}

h4 {
  font-size: 1.125rem;
  font-weight: 500;
  margin-top: 2rem;
}

h5 {
  font-size: 1rem;
  font-weight: 500;
}

h6 {
  font-size: 0.875rem;
  font-weight: 500;
}

h1,
h2,
h3 {
  line-height: 1.1;
}

small {
  font-size: 0.85em;
  color: var(--text-light);
}

del,
s {
  text-decoration: line-through;
  color: var(--text-light);
}

ins {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  color: var(--accent);
}

u {
  text-decoration: underline dotted;
  text-underline-offset: 0.15em;
}

var {
  font-family: var(--font-mono);
  font-style: normal;
  color: var(--code);
}

/* ==========================================
   5. Links
   ========================================== */

a,
a:visited {
  color: var(--accent);
}

a:hover {
  text-decoration: none;
  color: var(--accent-hover);
}

/* ==========================================
   6. Lists
   ========================================== */

ul,
ol {
  margin: 1.5rem 0;
  padding-left: 2rem;
  line-height: 1.6;
}

li {
  margin: 0.5rem 0;
  line-height: 1.6;
  letter-spacing: 0.01em;
}

li p {
  margin: 0.5rem 0;
}

li ul,
li ol {
  margin: 0.5rem 0;
}

dl {
  margin: 1.5rem 0;
}

dt {
  font-weight: 600;
  margin-top: 1rem;
}

dt:first-child {
  margin-top: 0;
}

dd {
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-light);
}

/* ==========================================
   7. Images & Figures
   ========================================== */

img {
  max-width: 100%;
  height: auto;
  display: block;
}

figure {
  margin: 1.5rem 0;
}

figure img {
  border-radius: var(--border-radius);
}

figcaption {
  font-size: 0.9rem;
  margin-top: 0.5rem;
  color: var(--text-light);
  text-align: center;
}

/* ==========================================
   8. Code
   ========================================== */

code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

/* Inline code */
p code,
li code,
td code {
  background: var(--accent-bg);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  color: var(--code);
}

/* Code blocks */
pre {
  background: #1e1e1e;
  color: #e0e0e0;
  padding: 1.5rem;
  margin: 2rem 0;
  border-radius: var(--border-radius);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85em;
  line-height: 1.5;
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
}

kbd {
  background: var(--accent-bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--border-radius);
  padding: 0.1rem 0.4rem;
}

/* ==========================================
   9. Blockquotes
   ========================================== */

blockquote {
  margin: 2rem 0;
  padding: 2rem 4vw;
  background: var(--accent-bg);
  border-left: none;
  font-family: var(--font-sans);
}

blockquote p {
  font-size: 97%;
  line-height: 1.6;
  margin: 0;
  letter-spacing: -0.01rem;
  color: var(--text);
}

blockquote p + p {
  margin-top: 1.2rem;
}

blockquote cite {
  display: block;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-light);
  font-style: normal;
}

blockquote cite::before {
  content: "\2014\00a0";
}

/* ==========================================
   10. Tables
   ========================================== */

table {
  border-collapse: collapse;
  margin: 1.5rem 0;
  width: 100%;
}

td,
th {
  border: 1px solid var(--border);
  text-align: start;
  padding: 0.5rem;
}

th {
  background-color: var(--accent-bg);
  font-weight: bold;
}

tr:nth-child(even) {
  background-color: var(--accent-bg);
}

table caption {
  font-weight: bold;
  margin-bottom: 0.5rem;
}

/* ==========================================
   11. Forms
   ========================================== */

textarea,
select,
input,
button,
[role="button"] {
  font-size: inherit;
  font-family: inherit;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  border-radius: var(--border-radius);
  box-shadow: none;
  max-width: 100%;
  display: inline-block;
}

textarea,
select,
input {
  color: var(--text);
  background-color: var(--bg);
  border: 1px solid var(--border);
}

label {
  display: block;
}

textarea:not([cols]) {
  width: 100%;
}

select:not([multiple]) {
  background-image: linear-gradient(45deg, transparent 49%, var(--text) 51%),
    linear-gradient(135deg, var(--text) 51%, transparent 49%);
  background-position: calc(100% - 15px), calc(100% - 10px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-end: 25px;
}

button,
input[type="submit"],
input[type="reset"],
input[type="button"],
[role="button"] {
  border: 1px solid var(--accent);
  background-color: var(--accent);
  color: var(--accent-text);
  padding: 0.5rem 0.9rem;
  text-decoration: none;
  line-height: normal;
  cursor: pointer;
}

button:hover,
input[type="submit"]:hover,
input[type="reset"]:hover,
input[type="button"]:hover,
[role="button"]:hover {
  opacity: 0.8;
}

input:disabled,
textarea:disabled,
select:disabled,
button[disabled] {
  cursor: not-allowed;
  background-color: var(--disabled);
  border-color: var(--disabled);
  color: var(--text-light);
}

input[type="checkbox"],
input[type="radio"] {
  vertical-align: middle;
  position: relative;
  width: min-content;
}

input[type="radio"] {
  border-radius: 100%;
}

input[type="color"] {
  padding: 0.2rem;
  height: 2.5rem;
  width: 4rem;
  cursor: pointer;
}

input[type="range"] {
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}

input[type="file"] {
  padding: 0;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  font: inherit;
  background-color: var(--accent);
  color: var(--accent-text);
  border: 0;
  padding: 0.5rem 0.9rem;
  margin-right: 0.5rem;
  border-radius: 0;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  opacity: 0.8;
}

meter {
  width: 100%;
  height: 1.2rem;
}

/* ==========================================
   12. Semantic Elements
   ========================================== */

article,
fieldset {
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
}

article h2:first-child,
article h3:first-child {
  margin-top: 1rem;
}

section {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 2rem 1rem;
  margin: 3rem 0;
}

section + section {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

details {
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
}

summary {
  cursor: pointer;
  font-weight: bold;
  padding: 0.5rem 0;
}

details[open] summary {
  margin-bottom: 0.5rem;
}

/* Navigation */
header > nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header > nav ul {
  margin: 0;
  padding: 0;
  display: flex;
  gap: 1.5rem;
  list-style: none;
  align-items: center;
}

header > nav ul li {
  margin: 0;
  padding: 0;
}

header > nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 450;
  transition: opacity 0.2s ease;
}

header > nav a:hover {
  opacity: 0.6;
  color: var(--accent-hover);
}

/* ==========================================
   13. ARIA & State
   ==========================================
   ARIA attributes are pilucho's escape hatch for component-like styling
   without classes. Use [role="button"] on an <a> to style it as a button,
   [aria-current="page"] on a nav link to mark it active, [aria-busy="true"]
   on any element to show a spinner, and so on.
   ========================================== */

/* Active page / current item in navigation */
[aria-current="page"],
[aria-current="true"] {
  font-weight: 600;
  color: var(--accent-hover);
}

/* Loading state — works on any element (buttons, sections, links) */
[aria-busy="true"] {
  cursor: progress;
}

[aria-busy="true"]::before {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 0.5em;
  vertical-align: -0.15em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: pilucho-spin 0.75s linear infinite;
}

@keyframes pilucho-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  [aria-busy="true"]::before {
    animation: none;
  }
}

/* Disabled state on non-form elements (e.g. <a role="button">) */
[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Invalid form input — pairs with native :invalid where appropriate */
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--accent-hover);
}

/* Inline notices: <p role="note">, <div role="status">, <div role="alert"> */
[role="alert"],
[role="status"],
[role="note"] {
  display: block;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: var(--border-radius);
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
}

[role="alert"] {
  border-left-color: var(--accent-hover);
}

/* Expandable trigger (accordion, disclosure, menu button) */
button[aria-expanded]::after,
[role="button"][aria-expanded]::after {
  content: "";
  display: inline-block;
  margin-left: 0.4em;
  border-left: 0.3em solid transparent;
  border-right: 0.3em solid transparent;
  border-top: 0.35em solid currentColor;
  vertical-align: middle;
  transition: transform 0.2s ease;
}

button[aria-expanded="true"]::after,
[role="button"][aria-expanded="true"]::after {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  button[aria-expanded]::after,
  [role="button"][aria-expanded]::after {
    transition: none;
  }
}

/* Toggle button (pressed/unpressed) — inverts to outline style when on */
button[aria-pressed="true"],
[role="button"][aria-pressed="true"] {
  background-color: var(--bg);
  color: var(--accent);
}

/* Selected item in a tablist, listbox, or option group */
[aria-selected="true"] {
  background-color: var(--accent-bg);
  font-weight: 600;
}

[role="tablist"] {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: 1.5rem 0 0 0;
}

[role="tab"] {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text);
  padding: 0.5rem 1rem;
  cursor: pointer;
  margin-bottom: -1px;
}

[role="tab"][aria-selected="true"] {
  background: none;
  border-bottom-color: var(--accent);
  color: var(--accent);
}

[role="tabpanel"] {
  padding: 1rem 0;
}

/* ==========================================
   14. Misc Elements
   ========================================== */

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

mark {
  background-color: var(--marked);
  padding: 0.1rem 0.2rem;
  border-radius: 2px;
}

abbr[title] {
  cursor: help;
  text-decoration: underline dotted;
}

sup,
sub {
  font-size: 0.75em;
}

dialog {
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  max-width: var(--content-width);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

aside {
  border-left: 3px solid var(--border);
  padding: 0 1rem;
  margin: 1.5rem 0;
  color: var(--text-light);
  font-size: 0.95rem;
}

/* Progress bar */
progress {
  width: 100%;
  height: 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  background-color: var(--accent-bg);
}

progress::-webkit-progress-bar {
  background-color: var(--accent-bg);
  border-radius: var(--border-radius);
}

progress::-webkit-progress-value {
  background-color: var(--accent);
  border-radius: var(--border-radius);
}

progress::-moz-progress-bar {
  background-color: var(--accent);
  border-radius: var(--border-radius);
}

/* ==========================================
   15. Responsive
   ========================================== */

@media only screen and (max-width: 720px) {
  h1 {
    font-size: 2rem;
  }
  h2 {
    font-size: 1.5rem;
  }
  h3 {
    font-size: 1.25rem;
  }

  body > header {
    padding: 1.5rem 0 1.5rem 0;
  }

  header > nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  header > nav ul {
    gap: 1rem;
    flex-wrap: wrap;
  }

  textarea,
  select,
  input {
    width: 100%;
  }

  table {
    display: block;
    overflow-x: auto;
  }

  blockquote {
    padding: 1rem;
  }
}

/* ==========================================
   16. Print
   ========================================== */

@media print {
  body {
    color: #000;
    background: #fff;
    grid-template-columns: 1fr;
    font-size: 11pt;
  }

  body > header,
  body > footer,
  nav {
    display: none;
  }

  main {
    padding: 0;
  }

  a,
  a:visited {
    color: #000;
    text-decoration: underline;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #555;
  }

  pre,
  blockquote,
  figure,
  table {
    page-break-inside: avoid;
  }

  h1,
  h2,
  h3 {
    page-break-after: avoid;
  }
}
