/* Factorial calculator - Bitcube styling */

:root {
    --bg: #0d0d0d;
    --surface: #1a1a1a;
    --surface-raised: #1e1e1e;
    --border: #2a2a2a;
    --text: #f5f5f5;
    --text-muted: #8a8a8a;
    --primary: #6025e1;
    --primary-hover: #7135f2;
    --primary-light: #9a6bff;
    --danger: #e84b2a;
    --radius: 0.375rem;
    --radius-lg: 1rem;
    --font-display: "Space Grotesk", "Segoe UI", Arial, sans-serif;
    --font-body: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.625;
    -webkit-font-smoothing: antialiased;
}

/* Ambient glow behind the hero, same trick as the Bitcube site */
body::before {
    content: "";
    position: fixed;
    top: -20vh;
    left: 50%;
    width: 80vw;
    height: 60vh;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center, rgba(96, 37, 225, 0.22), transparent 65%);
    pointer-events: none;
    z-index: 0;
}

/* ---------- Header ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    background-color: rgba(13, 13, 13, 0.72);
    backdrop-filter: blur(12px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -0.02em;
    color: var(--text);
    text-decoration: none;
}

.brand-logo {
    height: 30px;
    width: auto;
    display: block;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 28px;
}

.site-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.15s ease;
}

.site-nav a:hover {
    color: var(--text);
}

/* ---------- Layout ---------- */

.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 80px 24px 40px;
    flex: 1;
}

.container.wide {
    max-width: 820px;
}

/* ---------- Type ---------- */

h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 44px;
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin: 0 0 16px;
    text-align: center;
    color: oklch(70% 0.15 285);
}

h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 24px;
    letter-spacing: -0.02em;
    margin: 40px 0 12px;
    color: var(--text);
}

.lede {
    text-align: center;
    color: var(--text-muted);
    margin: 0 0 40px;
}

p {
    line-height: 1.8;
}

/* ---------- Form ---------- */

.calculator {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: 0 24px 48px -28px rgba(0, 0, 0, 0.75);
}

.field {
    margin: 0;
}

.field + .field {
    margin-top: 12px;
}

/* One message per box, sitting under the box it belongs to. An empty slot takes
   no room, so the form does not jump when a message appears. */
.field .error {
    display: block;
    margin-top: 6px;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.4;
    color: var(--danger);
}

.field .error:empty {
    display: none;
}

.form-control {
    display: block;
    width: 100%;
    padding: 14px 16px;
    background-color: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control::placeholder {
    color: #5a5a5a;
}

.form-control:hover {
    border-color: #3a3a3a;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(96, 37, 225, 0.3);
}

select.form-control {
    appearance: none;
    padding-right: 44px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%238a8a8a' stroke-width='1.6' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    cursor: pointer;
}

select.form-control option {
    background-color: var(--surface-raised);
    color: var(--text);
}

.btn {
    display: inline-block;
    padding: 14px 32px;
    text-decoration: none;
    line-height: 1.2;
    background-color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn:active {
    transform: translateY(1px);
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 3px;
}

/* Inside the card the button is the one thing to press, so it takes the width. */
.calculator .actions {
    margin-top: 20px;
}

.calculator .btn {
    display: block;
    width: 100%;
}

/* A link styled as a button still picks up the body-copy link colour. */
.content a.btn {
    color: #ffffff;
}

/* Body copy is left aligned, so its call to action is too. */
.content .actions {
    text-align: left;
    margin-top: 36px;
}

.actions {
    margin-top: 32px;
    text-align: center;
}

/* ---------- Result ---------- */

/* ---------- Published rules ---------- */

.section-title {
    margin: 0 0 12px;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.rules {
    list-style: none;
    margin: 0 0 28px;
    padding: 20px 24px;
    background-color: rgba(96, 37, 225, 0.07);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.65;
}

.rules li {
    position: relative;
    padding-left: 18px;
}

.rules li + li {
    margin-top: 8px;
}

.rules li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.62em;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: var(--primary-light);
}

/* ---------- Content pages ---------- */

.content a {
    color: var(--primary-light);
}

.content ul,
.content ol {
    line-height: 1.9;
    color: var(--text-muted);
}

.content p {
    color: var(--text-muted);
}

/* ---------- Footer ---------- */

.site-footer {
    position: relative;
    z-index: 1;
    padding: 32px 24px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-family: var(--font-display);
    font-size: 12px;
    color: var(--text-muted);
}

.site-footer a {
    color: var(--text-muted);
    text-decoration: none;
    margin: 0 12px;
}

.site-footer a:hover {
    color: var(--primary-light);
}

.copyright {
    margin-top: 12px;
}

grey-text {
    color: #7e7e7e;
    margin-top: 5px;
}

@media (max-width: 600px) {
    h1 { font-size: 32px; }
    .site-header { padding: 16px 20px; }
    .site-nav { gap: 16px; }
    .container { padding-top: 48px; }
}

/* ---------- App list on the landing page ---------- */

.app-list {
    list-style: none;
    margin: 32px 0 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.app-list a {
    display: block;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    text-decoration: none;
    transition: border-color 150ms, background-color 150ms;
}

.app-list a:hover {
    background: var(--surface-raised);
    border-color: var(--primary);
}

.app-list .app-name {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
}

.app-list .app-note {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ---------- Landing page hero ---------- */

.hero-logo {
    margin: 48px 0 20px;
}

.hero-logo a {
    display: inline-block;
}

.hero-logo img {
    height: 56px;
    width: auto;
    display: block;
}

/* ---------- Header action ---------- */

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-action {
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 150ms, background-color 150ms;
}

.header-action:hover {
    background: var(--surface-raised);
    border-color: var(--primary);
}

/* ---------- Result ---------- */

/* Its own box under the form, matching the rules card. It stays out of the way
   until there is something to show, so an untouched page is just the form. */
.result-card {
    display: none;
    margin-top: 24px;
    padding: 20px 24px;
    background-color: rgba(96, 37, 225, 0.07);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.result-card:has(.result-text:not(:empty)) {
    display: block;
}

.result-card p {
    margin: 0;
    /* The display face is only loaded at 700, so it always renders bold. */
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 19px;
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: anywhere;
    color: var(--text);
}

/* ---------- Saved quotes ---------- */

/* The kept quotes get their own box under the result, built the same way. It
   stays hidden until the first quote is saved. */
.saved-card {
    display: none;
    margin-top: 24px;
    padding: 20px 24px;
    background-color: rgba(96, 37, 225, 0.07);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.saved-card:has(.saved-row) {
    display: block;
}

.result-card .actions {
    margin-top: 16px;
    text-align: left;
}

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

.saved-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    color: var(--text-muted);
    font-size: 15px;
}

.saved-row + .saved-row {
    border-top: 1px solid var(--border);
}

.saved-detail {
    flex: 1;
}

.saved-price {
    color: var(--text);
    font-weight: 600;
}

.btn-remove {
    padding: 6px 12px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 13px;
    cursor: pointer;
}

.btn-remove:hover {
    border-color: var(--primary);
    color: var(--text);
}

.saved-total {
    margin: 16px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
}

/* ---------- Basket and confirmation ---------- */

/* The line under the result, counting what the basket holds. It takes no room
   until there is something in the basket to count. */
.basket-line {
    margin: 16px 0 0;
    color: var(--text-muted);
    font-size: 15px;
}

.basket-line:empty {
    display: none;
}

.basket-line a {
    color: var(--primary-light);
}

/* The empty basket message stands in for the card, so only one of the two is
   ever on the page. */
.basket-empty {
    margin: 24px 0 0;
    padding: 20px 24px;
    background-color: rgba(96, 37, 225, 0.07);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    text-align: center;
}

main:has(.saved-row) .basket-empty {
    display: none;
}

.basket-empty a {
    color: var(--primary-light);
}

/* The order summary, built like the saved quotes card. */
.confirm-card {
    margin-top: 24px;
    padding: 20px 24px;
    background-color: rgba(96, 37, 225, 0.07);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.order-ref {
    margin: 16px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
    text-align: center;
}

.order-ref:empty {
    display: none;
}

.basket-back {
    margin-top: 24px;
    text-align: center;
}

.basket-back a {
    color: var(--primary-light);
    font-size: 15px;
}

/* ---------- People and their shares ---------- */

/* The people paying get their own box under the name field, built like the saved
   quotes box. The script shows it once there is a list to show. */
.people-card {
    display: none;
    margin-top: 24px;
    padding: 20px 24px;
    background-color: rgba(96, 37, 225, 0.07);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

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

.people-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    color: var(--text-muted);
    font-size: 15px;
}

.people-row + .people-row {
    border-top: 1px solid var(--border);
}

.people-name {
    flex: 1;
    color: var(--text);
    font-weight: 600;
    word-break: break-word;
}

.people-percent {
    width: 140px;
    padding: 8px 10px;
    font-size: 15px;
}

.people-share {
    width: 120px;
    text-align: right;
    color: var(--text);
    font-weight: 600;
}

.people-total {
    margin: 16px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
}

/* ---------- Result breakdown ---------- */

/* The parking result is a small table inside the result card: one row for each
   part of the stay, with the charge last. */
.result-breakdown {
    margin: 0;
}

.result-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 10px 0;
    font-size: 15px;
}

.result-row + .result-row {
    border-top: 1px solid var(--border);
}

/* The variable rows are written into their own wrapper, so the row that follows
   it cannot see them as siblings and needs the divider drawn for it. */
#resultRows + .result-row {
    border-top: 1px solid var(--border);
}

.result-label {
    flex: 1;
    margin: 0;
    color: var(--text-muted);
}

.result-value {
    margin: 0;
    text-align: right;
    color: var(--text);
    font-weight: 600;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* The last row is the answer, so it gets more room and a bigger face than the
   rows above it. */
.result-row-answer {
    padding-top: 14px;
}

.result-row-answer .result-label {
    color: var(--text);
    font-weight: 600;
    font-size: 17px;
}

.result-row-answer .result-value {
    font-family: var(--font-display);
    font-size: 26px;
    line-height: 1.2;
}
