/*
Theme Name: Rankwell
Theme URI: https://example.com/rankwell
Author: Your Name
Description: An AI SEO tool theme. Includes a site audit / rank checker, AI keyword finder and AI article writer powered by the Claude API. Add your API key under Rankwell → Settings.
Version: 1.3.0
Requires at least: 6.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: rankwell
Tags: one-column, custom-menu, featured-images, seo, tools
*/

:root {
  --ink: #1b2a4a;
  --ink-soft: #4a5878;
  --page: #f6f8fc;
  --paper: #ffffff;
  --link: #2446d8;
  --link-visited: #5a33b8;
  --mark: #ffe45c;
  --rule: #d5dcea;
  --good: #1f8a5f;
  --warn: #b86e00;
  --bad: #c0392b;
  --radius-lg: 14px;
  --radius-sm: 6px;
  --font: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --wrap: 1120px;
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; border-radius: 4px; }

mark, .hl { background: var(--mark); color: inherit; padding: 0 .15em; border-radius: 2px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }

.screen-reader-text {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px); white-space: nowrap;
}
.skip-link:focus {
  clip: auto; width: auto; height: auto; top: 12px; left: 12px; z-index: 100;
  background: var(--paper); padding: 10px 16px; border-radius: var(--radius-sm);
}

/* ---------- Header ---------- */
.site-header { background: var(--paper); border-bottom: 1px solid var(--rule); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 68px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.25rem; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--mark); font-size: .95rem; font-weight: 800; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 22px; flex-wrap: wrap; }
.main-nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.main-nav a:hover { color: var(--link); text-decoration: underline; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 1rem;
  padding: 12px 22px; border-radius: 999px; border: 2px solid var(--ink);
  background: var(--ink); color: #fff; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--link); border-color: var(--link); color: #fff; }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--ink); border-color: var(--ink); }

label { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 6px; }
input[type="text"], input[type="url"], input[type="number"], input[type="email"], input[type="password"], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  padding: 12px 14px; border: 1.5px solid var(--rule); border-radius: var(--radius-sm); background: var(--paper);
}
input:focus, select:focus, textarea:focus { border-color: var(--link); outline: none; box-shadow: 0 0 0 3px rgba(36,70,216,.18); }
.field-hint { font-size: .85rem; color: var(--ink-soft); margin-top: 4px; }

/* ---------- Hero ---------- */
.hero { padding: 72px 0 64px; }
.hero .wrap { display: grid; grid-template-columns: 1fr 1.05fr; gap: 56px; align-items: center; }
.hero h1 { font-size: clamp(2.3rem, 5vw, 3.6rem); line-height: 1.05; letter-spacing: -.025em; margin: 0 0 20px; font-weight: 800; max-width: 14ch; }
.hero p.lede { font-size: 1.2rem; color: var(--ink-soft); max-width: 44ch; margin: 0 0 28px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* The mock results page */
.serp { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 22px 24px 8px; }
.serp-bar { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--rule); border-radius: 999px; padding: 10px 18px; margin-bottom: 18px; color: var(--ink); font-weight: 500; }
.serp-bar svg { flex: none; }
.serp-list { list-style: none; margin: 0; padding: 0; position: relative; }
.serp-item { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--rule); background: var(--paper); }
.serp-item:first-child { border-top: 0; }
.serp-pos { font-weight: 800; color: var(--ink-soft); font-variant-numeric: tabular-nums; padding-top: 2px; }
.serp-url { font-size: .82rem; color: var(--good); }
.serp-title { color: var(--link); font-size: 1.08rem; font-weight: 600; line-height: 1.3; }
.serp-desc { font-size: .9rem; color: var(--ink-soft); line-height: 1.45; }
.serp-item.is-you { box-shadow: inset 4px 0 0 var(--mark); padding-left: 10px; margin-left: -10px; }
.serp-item.is-you .serp-pos { color: var(--ink); }
.serp-you-tag { display: inline-block; font-size: .72rem; font-weight: 700; background: var(--ink); color: var(--mark); border-radius: 999px; padding: 1px 8px; margin-left: 6px; vertical-align: 2px; }

/* One orchestrated moment: your result climbs to #1 */
@media (prefers-reduced-motion: no-preference) {
  .serp-list.animate .serp-item { transition: transform .9s cubic-bezier(.2,.8,.2,1); }
}

/* ---------- Sections ---------- */
.section { padding: 72px 0; }
.section-alt { background: var(--paper); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.section h2 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); letter-spacing: -.02em; line-height: 1.1; margin: 0 0 12px; }
.section .intro { color: var(--ink-soft); max-width: 60ch; margin: 0 0 36px; font-size: 1.1rem; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 36px; counter-reset: step; }
.steps li { counter-increment: step; border-top: 3px solid var(--ink); padding-top: 18px; }
.steps li::before { content: "Step " counter(step); display: block; font-weight: 700; color: var(--link); margin-bottom: 6px; }
.steps h3 { margin: 0 0 6px; font-size: 1.25rem; }
.steps p { margin: 0; color: var(--ink-soft); }

/* ---------- Tool panel ---------- */
.tools { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-lg); overflow: hidden; }
.tool-tabs { display: flex; border-bottom: 1px solid var(--rule); overflow-x: auto; }
.tool-tab {
  font: inherit; font-weight: 700; font-size: 1rem; color: var(--ink-soft);
  background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 18px 24px; cursor: pointer; white-space: nowrap;
}
.tool-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tool-tab:hover { color: var(--ink); }
.tool-panel { padding: 28px; }
.tool-panel[hidden] { display: none; }
.tool-panel > p { margin-top: 0; color: var(--ink-soft); max-width: 65ch; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; align-items: end; }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; }
.btn-block { width: 100%; }

.status { margin-top: 20px; padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 500; }
.status:empty { display: none; }
.status.is-error { background: #fdecea; color: var(--bad); }
.status.is-loading { background: #eef2ff; color: var(--link); }
.status.is-loading::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -2px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .status.is-loading::before { animation: none; } }

.results { margin-top: 24px; }
.results:empty { display: none; }

/* Audit results */
.score-row { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; padding-bottom: 20px; border-bottom: 1px solid var(--rule); margin-bottom: 20px; }
.score-dial { --val: 0; --col: var(--good); width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--col) calc(var(--val) * 1%), var(--rule) 0); }
.score-dial span { width: 94px; height: 94px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; font-size: 2rem; font-weight: 800; }
.score-meta h3 { margin: 0 0 4px; font-size: 1.3rem; }
.score-meta p { margin: 0; color: var(--ink-soft); max-width: 60ch; }

.checks { list-style: none; padding: 0; margin: 0 0 24px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 32px; }
.checks li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: .95rem; }
.checks .dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 6px; }
.dot.good { background: var(--good); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.checks strong { display: block; }
.checks span.detail { color: var(--ink-soft); word-break: break-word; }

.fix-list { counter-reset: fix; list-style: none; padding: 0; margin: 0; }
.fix-list li { counter-increment: fix; display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding: 14px 0; border-top: 1px solid var(--rule); }
.fix-list li::before { content: counter(fix); font-weight: 800; font-size: 1.1rem; color: var(--link); }
.fix-list h4 { margin: 0 0 4px; font-size: 1.02rem; }
.fix-list p { margin: 0; color: var(--ink-soft); }
.impact { font-size: .78rem; font-weight: 700; border-radius: 999px; padding: 1px 9px; margin-left: 8px; vertical-align: 2px; }
.impact-high { background: #fdecea; color: var(--bad); }
.impact-medium { background: #fff4e0; color: var(--warn); }
.impact-low { background: #e6f5ee; color: var(--good); }

/* Keyword table */
.table-scroll { overflow-x: auto; }
.kw-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.kw-table th, .kw-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.kw-table th { font-size: .85rem; color: var(--ink-soft); font-weight: 600; cursor: pointer; white-space: nowrap; }
.kw-table th:hover { color: var(--ink); }
.kw-table td:first-child { font-weight: 600; }
.diff-bar { display: inline-block; width: 60px; height: 8px; background: var(--rule); border-radius: 99px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.diff-bar i { display: block; height: 100%; }
.kw-use { font: inherit; font-size: .85rem; font-weight: 600; color: var(--link); background: none; border: 0; cursor: pointer; padding: 0; text-decoration: underline; }
.table-note { font-size: .85rem; color: var(--ink-soft); margin-top: 10px; }

/* Article output */
.article-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; padding-bottom: 16px; border-bottom: 1px solid var(--rule); margin-bottom: 20px; }
.article-head dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .92rem; }
.article-head dt { font-weight: 700; }
.article-head dd { margin: 0; color: var(--ink-soft); }
.article-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.article-body { max-width: 72ch; }
.article-body h1 { font-size: 2rem; line-height: 1.15; letter-spacing: -.02em; }
.article-body h2 { font-size: 1.45rem; margin-top: 1.8em; }
.article-body h3 { font-size: 1.15rem; }

/* ---------- Blog ---------- */
.post-list { display: grid; gap: 0; }
.post-card { padding: 28px 0; border-bottom: 1px solid var(--rule); }
.post-card h2 { font-size: 1.5rem; margin: 0 0 6px; }
.post-card h2 a { color: var(--ink); text-decoration: none; }
.post-card h2 a:hover { color: var(--link); text-decoration: underline; }
.post-meta { font-size: .9rem; color: var(--ink-soft); margin-bottom: 10px; }
.entry { max-width: 72ch; margin: 0 auto; padding: 56px 24px; }
.entry h1 { font-size: clamp(2rem, 4.5vw, 3rem); line-height: 1.1; letter-spacing: -.02em; margin: 0 0 12px; }
.entry-content h2 { margin-top: 1.8em; }
.entry-content blockquote { border-left: 4px solid var(--mark); margin: 1.5em 0; padding: .2em 1.2em; color: var(--ink-soft); }
.pagination { padding: 32px 0; display: flex; gap: 12px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--rule); background: var(--paper); padding: 36px 0; font-size: .95rem; color: var(--ink-soft); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero .wrap { grid-template-columns: 1fr; gap: 40px; }
  .steps { grid-template-columns: 1fr; gap: 24px; }
  .checks { grid-template-columns: 1fr; }
  .col-8, .col-6, .col-4, .col-3, .col-2 { grid-column: span 12; }
}
@media (max-width: 560px) {
  .hero { padding: 44px 0; }
  .tool-panel { padding: 20px; }
  .serp { padding: 16px 16px 4px; }
}

.kw-actions { white-space: nowrap; }
.kw-actions .kw-use + .kw-use { margin-left: 14px; }
.kw-use[disabled] { color: var(--good); text-decoration: none; cursor: default; }

/* ---------- Latest articles (homepage) ---------- */
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.section-head h2 { margin: 0; }
.post-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 36px 28px; }
.post-tile-link { display: block; color: var(--ink); text-decoration: none; }
.post-tile-img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: var(--ink); margin-bottom: 12px; }
.post-tile-empty { display: grid; place-items: center; color: var(--mark); font-weight: 800; font-size: 2rem; width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; background: var(--ink); }
.post-tile-date { display: block; font-size: .85rem; color: var(--ink-soft); margin-bottom: 4px; }
.post-tile-title { margin: 0; font-size: 1.15rem; line-height: 1.3; }
.post-tile-link:hover .post-tile-title { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.post-tile-link:focus-visible { outline-offset: 6px; }

/* ---------- Blog list with small images ---------- */
.post-card { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.post-card-thumb img, .post-card-thumb .post-tile-empty { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; }
.post-card p { margin: 0; color: var(--ink-soft); max-width: 65ch; }

.entry-thumb { margin: 24px 0 32px; }
.entry-thumb img { display: block; width: 100%; border-radius: 12px; }
.photo-credit { font-size: .85rem; color: var(--ink-soft); margin: 8px 0 0; }
.photo-credit a { color: inherit; }

@media (max-width: 900px) { .post-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) {
  .post-grid { grid-template-columns: 1fr; }
  .post-card { grid-template-columns: 110px 1fr; gap: 16px; }
  .post-card h2 { font-size: 1.15rem; }
  .post-card p { display: none; }
}

/* ---------- Accounts ---------- */
.header-account { display: flex; align-items: center; gap: 16px; }
.header-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.header-link:hover { color: var(--link); text-decoration: underline; }
.btn-small { padding: 8px 16px; font-size: .92rem; }
.main-nav { margin-left: auto; }

.tool-account { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap;
  padding: 14px 24px; background: #fffbe0; border-bottom: 1px solid var(--rule); }
.tool-account p { margin: 0; }
.tool-account-actions { display: flex; align-items: center; gap: 16px; }
.pro-badge { display: inline-block; font-size: .7rem; font-weight: 800; letter-spacing: .02em; background: var(--mark); color: var(--ink); border-radius: 99px; padding: 1px 8px; margin-left: 6px; vertical-align: 2px; }
.status-link { font-weight: 700; color: inherit; }

.account { padding: 56px 24px 72px; max-width: 980px; }
.account h1 { font-size: clamp(2rem, 4.5vw, 2.8rem); line-height: 1.1; letter-spacing: -.02em; margin: 0 0 10px; }
.account .intro { color: var(--ink-soft); font-size: 1.1rem; max-width: 60ch; margin: 0 0 32px; }
.notice { padding: 12px 16px; border-radius: var(--radius-sm); background: #eef2ff; color: var(--ink); margin: 0 0 24px; }
.notice-error { background: #fdecea; color: var(--bad); }
.notice-success { background: #e6f5ee; color: #14573c; }

.auth-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 28px; align-items: start; }
.auth-box { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 28px; scroll-margin-top: 24px; }
.auth-primary { border: 2px solid var(--ink); }
.auth-box h2 { margin: 0 0 16px; font-size: 1.4rem; }
.auth-box p { margin: 0 0 16px; }
.auth-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .95rem; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; margin: 0; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.plan-box { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; align-items: flex-start;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 28px; margin: 8px 0 24px; }
.plan-box.is-pro { box-shadow: inset 5px 0 0 var(--mark); }
.plan-label { margin: 0; font-size: .9rem; color: var(--ink-soft); font-weight: 600; }
.plan-box h2 { margin: 2px 0 6px; font-size: 1.8rem; }
.plan-meta { margin: 0 0 12px; color: var(--ink-soft); }
.plan-main { flex: 1 1 320px; }
.plan-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.plan-actions form { margin: 0; }
.usage { margin-top: 14px; max-width: 420px; }
.usage-bar { height: 10px; background: var(--rule); border-radius: 99px; overflow: hidden; }
.usage-bar i { display: block; height: 100%; background: var(--link); }
.usage p { margin: 8px 0 0; font-size: .95rem; }

.upgrade-box { display: grid; grid-template-columns: 1fr auto; gap: 24px 40px; align-items: center;
  border: 2px solid var(--ink); border-radius: var(--radius-lg); padding: 28px; background: var(--paper); scroll-margin-top: 24px; }
.upgrade-box.is-highlighted { box-shadow: 0 0 0 6px var(--mark); }
.upgrade-box h2 { margin: 0 0 12px; }
.upgrade-cta { text-align: center; }
.upgrade-cta .price, .plan .price { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 12px; }
.upgrade-cta .field-hint { margin-top: 8px; }

.ticks { list-style: none; padding: 0; margin: 0; }
.ticks li { position: relative; padding: 5px 0 5px 28px; }
.ticks li::before { content: ""; position: absolute; left: 4px; top: .75em; width: 12px; height: 7px; border-left: 3px solid var(--good); border-bottom: 3px solid var(--good); transform: rotate(-45deg); }

.account-foot { margin-top: 40px; color: var(--ink-soft); font-size: .95rem; }

/* ---------- Pricing (homepage) ---------- */
.plans { display: grid; grid-template-columns: repeat(2, minmax(0, 360px)); gap: 28px; }
.plan { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 28px; display: flex; flex-direction: column; }
.plan h3 { margin: 0 0 6px; font-size: 1.25rem; }
.plan .ticks { margin-bottom: 24px; flex: 1; }
.plan-pro { border: 2px solid var(--ink); }
.plan-current { margin: 0; font-weight: 700; color: var(--good); }

@media (max-width: 800px) {
  .auth-grid, .upgrade-box, .plans { grid-template-columns: 1fr; }
  .upgrade-cta { text-align: left; }
  .header-account .btn-small { display: none; }
}
