/* Overrides on top of Pico; keep this file small. */
@font-face {
  font-family: "Nanum Gothic";
  src: url("/static/nanum-gothic-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Nanum Gothic";
  src: url("/static/nanum-gothic-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --pico-font-family-sans-serif: "Nanum Gothic", system-ui, sans-serif;
  --pico-font-size: 100%;
}

body > header.container,
body > main.container {
  max-width: 72rem;
}

body > header nav form { margin: 0; }

/* Buttons are plain text with a loose underline. Hover may only change color: sizing set in a
   hover rule fights Pico's nav button padding and makes the header jump. */
:is(button, [type="submit"], [type="button"], [type="reset"], [role="button"]) {
  width: auto;
  margin: 0;
  padding: 0;
  font-weight: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.35em;
}

:is(button, [type="submit"], [type="button"], [type="reset"], [role="button"]),
:is(button, [type="submit"], [type="button"], [type="reset"], [role="button"]):is(:hover, :active, :focus) {
  --pico-background-color: transparent;
  --pico-border-color: transparent;
  --pico-box-shadow: none;
  --pico-color: inherit;
}

/* Pico makes submit buttons full width with a more specific selector. */
button[type="submit"] { width: auto; }

/* Header links look like the header buttons. */
body > header nav a:not(.brand) {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.35em;
}
body > header nav a:not(.brand):hover { color: var(--pico-primary-hover); }

:is(button, [type="submit"], [type="button"], [type="reset"], [role="button"]):hover {
  --pico-color: var(--pico-primary-hover);
}

:is(button, [type="submit"], [type="button"], [type="reset"], [role="button"]):focus-visible {
  outline: 2px solid var(--pico-primary-focus);
  outline-offset: 3px;
}
.brand { font-weight: 700; text-decoration: none; color: var(--pico-color); }

.muted { color: var(--pico-muted-color); }
.error { color: var(--pico-del-color); }

.login { max-width: 22rem; margin: 3rem auto; }

.recipe-list { padding: 0; }
.recipe-list li { list-style: none; padding: 0.5rem 0; border-bottom: 1px solid var(--pico-muted-border-color); }

.actions { display: flex; gap: 1.25rem; align-items: baseline; flex-wrap: wrap; }
.actions form { margin: 0; }

.recipe-header { margin-bottom: 2rem; }
.details { display: flex; gap: 1rem; flex-wrap: wrap; }
.tags a { margin-right: 0.5rem; }

.recipe-body { display: grid; gap: 2rem; }
@media (min-width: 768px) {
  .recipe-body { grid-template-columns: minmax(16rem, 1fr) 2fr; }
}
.ingredients { padding-left: 1rem; }
.ingredients li { list-style: none; margin-bottom: 0.35rem; }
.steps li { margin-bottom: 0.75rem; }
.notes { white-space: pre-wrap; }

/* The gutter is an invisible copy of the text laid over the textarea; it wraps the same way,
   so each number sits on the first row of its line even when the line wraps. */
.numbered-editor {
  --gutter-width: 3rem;
  position: relative;
  margin-bottom: var(--pico-spacing);
}

textarea.markdown,
.line-numbers {
  font-family: var(--pico-font-family-monospace);
  font-size: 0.9rem;
  line-height: 1.5;
  padding: var(--pico-form-element-spacing-vertical) var(--pico-form-element-spacing-horizontal);
  padding-left: calc(var(--gutter-width) + var(--pico-form-element-spacing-horizontal));
  border: var(--pico-border-width) solid transparent;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  scrollbar-gutter: stable;
}

textarea.markdown {
  display: block;
  margin-bottom: 0;
  border-color: var(--pico-form-element-border-color);
}

.line-numbers {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: transparent;
  pointer-events: none;
  counter-reset: line;
}

.line-numbers .line {
  position: relative;
  counter-increment: line;
}

.line-numbers .line::before {
  content: counter(line);
  position: absolute;
  left: calc(-1 * var(--gutter-width));
  width: calc(var(--gutter-width) - 0.75rem);
  text-align: right;
  color: var(--pico-muted-color);
}

.versions { padding-left: 1.25rem; }
.versions li { margin-bottom: 1.25rem; }
.versions pre { white-space: pre-wrap; padding: 1rem; }

.editor { display: grid; gap: 2rem; }
@media (min-width: 1024px) {
  .editor { grid-template-columns: 2fr 1fr; align-items: start; }
}
.format-guide { font-size: 0.9rem; }
.format-guide h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.format-guide pre { padding: 1rem; font-size: 0.85rem; line-height: 1.5; }
.format-guide ul { padding-left: 1rem; }

.import { margin-bottom: 2rem; }
.import-row { display: flex; gap: 1.25rem; align-items: center; margin-bottom: 0.5rem; }
.import-row input { margin-bottom: 0; }
