/* bebas-neue-regular - latin */
@font-face {
    font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'Bebas Neue';
    font-style: normal;
    font-weight: 400;
    src: url('../fonts/bebas-neue-v16-latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}
/* ibm-plex-mono-regular - latin */
@font-face {
    font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 400;
    src: url('../fonts/ibm-plex-mono-v20-latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}
/* ibm-plex-mono-600 - latin */
@font-face {
    font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 600;
    src: url('../fonts/ibm-plex-mono-v20-latin-600.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

:root {
    --oll: #c87000;
    --oll2: #8a3e00;
    --pll: #005fa3;
    --pll2: #003f75;
    --f2l: #1a7a3a;
    --f2l2: #0f4d24;
    --border: #e0e0e0;
    --muted: #888;
    --trigger1: #e50800f6;
    --trigger2: #8031A7;
    --trigger3: #ca49c4;
    --trigger4: #3b20d4;
    --tab-h: 73px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    /* Scale: change this to resize everything */
    font-size: 17px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    background: #fafafa;
    font-family: "IBM Plex Mono", monospace;
    color: #111;
    overscroll-behavior: none;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ── Topbar ── */
#topbar {
    background: #111;
    color: #fff;
    padding: 12px 16px 10px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    flex-shrink: 0;
}

#topbar-row1 {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 9px;
}

#topbar h1 {
    font-family: "Bebas Neue", sans-serif;
    font-size: 1.95rem;
    letter-spacing: 0.18em;
}

#topbar-subtitle {
    font-size: 0.81rem;
    color: #666;
    letter-spacing: 0.12em;
    flex: 1;
}

/* Scale button inside topbar */
#scale-btn {
    background: #2a2a2a;
    border: none;
    border-radius: 7px;
    color: #888;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    align-self: center;
}

#scale-btn:active {
    background: #444;
    color: #fff;
}

/* Search bar */
#search-wrap {
    position: relative;
    display: none;
}

#search-wrap.visible {
    display: block;
}

#search-input {
    width: 100%;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    color: #eee;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.85rem;
    padding: 7px 32px 7px 12px;
    outline: none;
    transition: border-color 0.15s;
}

#search-input::placeholder {
    color: #555;
}

#search-input:focus {
    border-color: #555;
}

#search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #555;
    font-size: 1rem;
    cursor: pointer;
    display: none;
    line-height: 1;
    padding: 0;
}

#search-clear.visible {
    display: block;
}

/* ── Scroll area ── */
#scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 16px 16px calc(var(--tab-h) + var(--safe-b) + 21px);
}

/* ── Panels ── */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ── Section labels ── */
.section-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 21px 0 10px;
    font-family: "Bebas Neue", sans-serif;
    font-size: 0.94rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.section-label:first-child {
    margin-top: 4px;
}

.section-label::after {
    content: "";
    flex: 1;
    height: 1px;
    background: currentColor;
    opacity: 0.2;
}

.section-label.oll {
    color: var(--oll2);
}

.section-label.pll {
    color: var(--pll2);
}

.section-label.f2l {
    color: var(--f2l2);
}

.section-label.ref {
    color: #666;
}

/* ── Cards ── */
.card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 13px 16px;
    margin-bottom: 9px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f0f0f0;
    cursor: pointer;
    transition: transform 0.1s, filter 0.1s;
    -webkit-user-select: none;
    user-select: none;
}

.card:active {
    transform: scale(0.98);
    filter: brightness(0.93);
}

/* Colour variants */
.card.pll {
    background: #e4eef8;
    border-color: #bed0e6;
}

.card.f2l,
.card.f2l-case {
    background: #e4f2eb;
    border-color: #b0d4bc;
}

.card.f2l {
    cursor: default;
}

.card.f2l:active {
    transform: none;
    filter: none;
}

.card img {
    width: 68px;
    height: 68px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 5px;
}

.card-top {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

/* Chevron for clickable cards */
.card[data-alg] .card-top::after {
    content: "›";
    font-size: 1.95rem;
    color: #ccc;
    flex-shrink: 0;
    line-height: 1;
    margin-left: auto;
    padding-left: 8px;
}

.card.f2l-case[data-alg] .card-top::after {
    color: #a8cdb6;
}

/* Card name */
.card-name {
    font-family: "Bebas Neue", sans-serif;
    font-size: 0.94rem;
    letter-spacing: 0.1em;
    color: var(--oll);
}

.card.pll .card-name {
    color: var(--pll);
}

.card.f2l .card-name,
.card.f2l-case .card-name {
    color: var(--f2l);
}

/* Algorithm text */
.alg {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #111;
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
    width: 100%;
}

.card.pll .alg {
    color: var(--pll2);
}

.card.f2l .alg,
.card.f2l-case .alg {
    color: var(--f2l2);
}

.card.f2l-case .alg {
    font-size: 0.98rem;
}

.alg-alt {
    display: block;
    font-size: 0.88rem;
    font-weight: 400;
    color: var(--f2l2);
    opacity: 0.7;
    line-height: 1.35;
    white-space: normal;
    word-break: break-word;
    margin-top: 2px;
    width: 100%;
}

/* Tip cards — visually distinct from algo cards */
.card.tip {
    background: #f5f0e8;
    border-color: #ddd0b8;
    cursor: default;
    border-left: 3px solid #c8a84b;
}

.card.tip:active {
    transform: none;
    filter: none;
}

.card.tip .card-name {
    color: #7a5c1a;
    font-style: normal;
}

.card.tip .hint {
    color: #6b5a3a;
}

/* Alt alg label */
.alg-alt-label {
    font-family: "Bebas Neue", sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    color: var(--muted);
    opacity: 0.8;
    margin-right: 5px;
}

/* Active card (popup open) */
.card.popup-active {
    outline: 2px solid currentColor;
    outline-offset: 1px;
    opacity: 0.85;
}

.trigger1 {
    color: var(--trigger1);
}

.trigger2 {
    color: var(--trigger2);
}

.trigger3 {
    color: var(--trigger3);
}

.trigger4 {
    color: var(--trigger4);
}

.hint {
    display: block;
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.3;
    margin-top: 3px;
    white-space: normal;
}

/* ── Notation table ── */
.notation-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    font-size: 0.78rem;
}

.notation-table tr {
    border-bottom: 1px solid #f0f0f0;
}

.notation-table tr:last-child {
    border-bottom: none;
}

.notation-table td {
    padding: 5px 12px;
    line-height: 1.4;
}

.n-group {
    font-family: "Bebas Neue", sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    color: var(--muted);
    background: #ebebeb;
    padding: 4px 12px;
    border-bottom: 1px solid var(--border);
}

.n-std {
    font-weight: 600;
    width: 2.2em;
}

.n-move {
    width: 3em;
    color: var(--muted);
}

.n-desc {
    color: var(--muted);
}

.n-prime {
    opacity: 0.55;
    font-size: 0.85em;
    padding-left: 2px;
}

.notation-note {
    font-size: 0.68rem;
    color: var(--muted);
    padding: 4px 12px;
    border-top: 1px solid var(--border);
    background: #ebebeb;
}

/* ── Tab bar ── */
#tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--tab-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    background: #111;
    display: flex;
    border-top: 1px solid #2a2a2a;
    z-index: 100;
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.tab-btn:active {
    background: #1e1e1e;
}

.tab-label {
    font-family: "Bebas Neue", sans-serif;
    font-size: 1.1rem;
    letter-spacing: 0.14em;
    color: #444;
    transition: color 0.15s;
}

.tab-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.15s;
}

/* Active tab colours */
.tab-btn.active[data-tab="f2l"] .tab-label {
    color: #4ecb76;
}

.tab-btn.active[data-tab="f2l"] .tab-dot {
    background: #4ecb76;
}

.tab-btn.active[data-tab="oll"] .tab-label {
    color: #f0a030;
}

.tab-btn.active[data-tab="oll"] .tab-dot {
    background: #f0a030;
}

.tab-btn.active[data-tab="pll"] .tab-label {
    color: #4a9fdf;
}

.tab-btn.active[data-tab="pll"] .tab-dot {
    background: #4a9fdf;
}

.tab-btn.active[data-tab="ref"] .tab-label {
    color: #aaa;
}

.tab-btn.active[data-tab="ref"] .tab-dot {
    background: #aaa;
}

/* ── Overlay / Popup ── */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 21px;
}

.overlay.active {
    display: flex;
}

.popup {
    background: #fff;
    border-radius: 18px;
    width: min(460px, 100%);
    position: relative;
    animation: popIn 0.2s ease;
    overflow: hidden;
}

@keyframes popIn {
    from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
    }

    to {
    opacity: 1;
    transform: scale(1) translateY(0);
    }
}

.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 21px 16px;
    border-bottom: 1px solid var(--border);
}

.popup-title-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.popup-type {
    font-family: "Bebas Neue", sans-serif;
    font-size: 0.78rem;
    letter-spacing: 0.2em;
}

.popup-type.oll {
    color: var(--oll);
}

.popup-type.pll {
    color: var(--pll);
}

.popup-type.f2l {
    color: var(--f2l);
}

.popup-name {
    font-family: "Bebas Neue", sans-serif;
    font-size: 1.56rem;
    letter-spacing: 0.07em;
    color: #111;
}

.popup-close {
    background: #f0f0f0;
    border: none;
    color: #555;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.popup-close:active {
    background: #ddd;
}

.popup-body {
  padding: 14px 21px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.popup-algo {
  font-size: 1.05rem;
  font-weight: 600;
  color: #111;
  line-height: 1.4;
}

.popup-setup {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}

#cube-container {
    display: flex;
    justify-content: center;
    background: #fafafa;
    padding: 10px 0;
}

/* ── Scale button ── */
#scale-btn {
    position: fixed;
    top: calc(14px + env(safe-area-inset-top, 0px));
    right: 14px;
    background: #2a2a2a;
    border: none;
    border-radius: 8px;
    color: #bbb;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    padding: 5px 9px;
    cursor: pointer;
    z-index: 300;
    transition: background 0.15s, color 0.15s;
}

#scale-btn:active {
    background: #444;
    color: #fff;
}
